@@ -6,35 +6,35 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
| 8 | 8 | { |
| 9 | - public static $files = array ( |
|
| 9 | + public static $files = array( |
|
| 10 | 10 | 'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php', |
| 11 | 11 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
| 12 | 12 | '42671a413efb740d7040437ff2a982cd' => __DIR__ . '/..' . '/ayecode/wp-super-duper/sd-functions.php', |
| 13 | 13 | ); |
| 14 | 14 | |
| 15 | - public static $prefixLengthsPsr4 = array ( |
|
| 15 | + public static $prefixLengthsPsr4 = array( |
|
| 16 | 16 | 'M' => |
| 17 | - array ( |
|
| 17 | + array( |
|
| 18 | 18 | 'MaxMind\\Db\\' => 11, |
| 19 | 19 | ), |
| 20 | 20 | 'C' => |
| 21 | - array ( |
|
| 21 | + array( |
|
| 22 | 22 | 'Composer\\Installers\\' => 20, |
| 23 | 23 | ), |
| 24 | 24 | ); |
| 25 | 25 | |
| 26 | - public static $prefixDirsPsr4 = array ( |
|
| 26 | + public static $prefixDirsPsr4 = array( |
|
| 27 | 27 | 'MaxMind\\Db\\' => |
| 28 | - array ( |
|
| 28 | + array( |
|
| 29 | 29 | 0 => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db', |
| 30 | 30 | ), |
| 31 | 31 | 'Composer\\Installers\\' => |
| 32 | - array ( |
|
| 32 | + array( |
|
| 33 | 33 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
| 34 | 34 | ), |
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | - public static $classMap = array ( |
|
| 37 | + public static $classMap = array( |
|
| 38 | 38 | 'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php', |
| 39 | 39 | 'AyeCode_Deactivation_Survey' => __DIR__ . '/..' . '/ayecode/wp-deactivation-survey/wp-deactivation-survey.php', |
| 40 | 40 | 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public static function getInitializer(ClassLoader $loader) |
| 45 | 45 | { |
| 46 | - return \Closure::bind(function () use ($loader) { |
|
| 46 | + return \Closure::bind(function() use ($loader) { |
|
| 47 | 47 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
| 48 | 48 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
| 49 | 49 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |
@@ -312,9 +312,9 @@ |
||
| 312 | 312 | foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { |
| 313 | 313 | if (isset(self::$installedByVendor[$vendorDir])) { |
| 314 | 314 | $installed[] = self::$installedByVendor[$vendorDir]; |
| 315 | - } elseif (is_file($vendorDir.'/composer/installed.php')) { |
|
| 316 | - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; |
|
| 317 | - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
| 315 | + } elseif (is_file($vendorDir . '/composer/installed.php')) { |
|
| 316 | + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir . '/composer/installed.php'; |
|
| 317 | + if (null === self::$installed && strtr($vendorDir . '/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { |
|
| 318 | 318 | self::$installed = $installed[count($installed) - 1]; |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -14,9 +14,9 @@ |
||
| 14 | 14 | } |
| 15 | 15 | if (!ini_get('display_errors')) { |
| 16 | 16 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
| 17 | - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); |
|
| 17 | + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL . PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL . PHP_EOL); |
|
| 18 | 18 | } elseif (!headers_sent()) { |
| 19 | - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; |
|
| 19 | + echo 'Composer detected issues in your platform:' . PHP_EOL . PHP_EOL . str_replace('You are running ' . PHP_VERSION . '.', '', implode(PHP_EOL, $issues)) . PHP_EOL . PHP_EOL; |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | trigger_error( |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) { |
|
| 7 | +if (!class_exists('AyeCode_Deactivation_Survey')) { |
|
| 8 | 8 | |
| 9 | 9 | class AyeCode_Deactivation_Survey { |
| 10 | 10 | |
@@ -21,18 +21,18 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public $version = "1.0.4"; |
| 23 | 23 | |
| 24 | - public static function instance( $plugin = array() ) { |
|
| 25 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) { |
|
| 24 | + public static function instance($plugin = array()) { |
|
| 25 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_Deactivation_Survey)) { |
|
| 26 | 26 | self::$instance = new AyeCode_Deactivation_Survey; |
| 27 | 27 | self::$plugins = array(); |
| 28 | 28 | |
| 29 | - add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) ); |
|
| 29 | + add_action('admin_enqueue_scripts', array(self::$instance, 'scripts')); |
|
| 30 | 30 | |
| 31 | - do_action( 'ayecode_deactivation_survey_loaded' ); |
|
| 31 | + do_action('ayecode_deactivation_survey_loaded'); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if(!empty($plugin)){ |
|
| 35 | - self::$plugins[] = (object)$plugin; |
|
| 34 | + if (!empty($plugin)) { |
|
| 35 | + self::$plugins[] = (object) $plugin; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return self::$instance; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | global $pagenow; |
| 43 | 43 | |
| 44 | 44 | // Bail if we are not on the plugins page |
| 45 | - if ( $pagenow != "plugins.php" ) { |
|
| 45 | + if ($pagenow != "plugins.php") { |
|
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | 'other' => 'Other', |
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | - foreach($plugins as $plugin) |
|
| 88 | + foreach ($plugins as $plugin) |
|
| 89 | 89 | { |
| 90 | 90 | $plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin); |
| 91 | 91 | $plugin->url = home_url(); |
@@ -5,9 +5,9 @@ discard block |
||
| 5 | 5 | * @package GetPaid |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | -include plugin_dir_path( __FILE__ ) . 'rapid-addon.php'; |
|
| 10 | +include plugin_dir_path(__FILE__) . 'rapid-addon.php'; |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * WP All Import class. |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | public function __construct() { |
| 35 | 35 | |
| 36 | 36 | // Init each store separately. |
| 37 | - foreach ( array_keys( $this->datastores ) as $key ) { |
|
| 38 | - $this->init_store( $key ); |
|
| 37 | + foreach (array_keys($this->datastores) as $key) { |
|
| 38 | + $this->init_store($key); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | } |
@@ -43,51 +43,51 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * Inits a store. |
| 45 | 45 | */ |
| 46 | - public function init_store( $key ) { |
|
| 46 | + public function init_store($key) { |
|
| 47 | 47 | |
| 48 | 48 | // Register the add-on. |
| 49 | - $this->add_ons[ $key ] = new RapidAddon( 'GetPaid', 'getpaid_wp_al_import_' . $key ); |
|
| 49 | + $this->add_ons[$key] = new RapidAddon('GetPaid', 'getpaid_wp_al_import_' . $key); |
|
| 50 | 50 | |
| 51 | 51 | // Create import function. |
| 52 | - $import_function = function ( $post_id, $data, $import_options, $_post ) use ( $key ) { |
|
| 53 | - $this->import_store( $key, $post_id, $data, $import_options, $_post ); |
|
| 52 | + $import_function = function($post_id, $data, $import_options, $_post) use ($key) { |
|
| 53 | + $this->import_store($key, $post_id, $data, $import_options, $_post); |
|
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | - $this->add_ons[ $key ]->set_import_function( $import_function ); |
|
| 56 | + $this->add_ons[$key]->set_import_function($import_function); |
|
| 57 | 57 | |
| 58 | 58 | // Register store fields. |
| 59 | - $this->add_store_fields( $key ); |
|
| 59 | + $this->add_store_fields($key); |
|
| 60 | 60 | |
| 61 | 61 | // Only load on the correct post type. |
| 62 | - $this->add_ons[ $key ]->run( array( 'post_types' => array( 'wpi_' . $key ) ) ); |
|
| 62 | + $this->add_ons[$key]->run(array('post_types' => array('wpi_' . $key))); |
|
| 63 | 63 | |
| 64 | 64 | // Disable images. |
| 65 | - $this->add_ons[ $key ]->disable_default_images(); |
|
| 65 | + $this->add_ons[$key]->disable_default_images(); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Retrieves store fields. |
| 71 | 71 | */ |
| 72 | - public function get_store_fields( $key ) { |
|
| 72 | + public function get_store_fields($key) { |
|
| 73 | 73 | |
| 74 | 74 | // Fetch from data/invoice-schema.php, from data/discount-schema.php, from data/item-schema.php |
| 75 | - $fields = wpinv_get_data( $key . '-schema' ); |
|
| 75 | + $fields = wpinv_get_data($key . '-schema'); |
|
| 76 | 76 | |
| 77 | - if ( empty( $fields ) ) { |
|
| 77 | + if (empty($fields)) { |
|
| 78 | 78 | return array(); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Clean the fields. |
| 82 | 82 | $prepared = array(); |
| 83 | - foreach ( $fields as $id => $field ) { |
|
| 83 | + foreach ($fields as $id => $field) { |
|
| 84 | 84 | |
| 85 | 85 | // Skip read only fields. |
| 86 | - if ( ! empty( $field['readonly'] ) ) { |
|
| 86 | + if (!empty($field['readonly'])) { |
|
| 87 | 87 | continue; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $prepared[ $id ] = $field; |
|
| 90 | + $prepared[$id] = $field; |
|
| 91 | 91 | |
| 92 | 92 | } |
| 93 | 93 | |
@@ -98,10 +98,10 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * Registers store fields. |
| 100 | 100 | */ |
| 101 | - public function add_store_fields( $key ) { |
|
| 101 | + public function add_store_fields($key) { |
|
| 102 | 102 | |
| 103 | - foreach ( $this->get_store_fields( $key ) as $field_id => $data ) { |
|
| 104 | - $this->add_ons[ $key ]->add_field( $field_id, $data['description'], 'text' ); |
|
| 103 | + foreach ($this->get_store_fields($key) as $field_id => $data) { |
|
| 104 | + $this->add_ons[$key]->add_field($field_id, $data['description'], 'text'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | } |
@@ -109,36 +109,36 @@ discard block |
||
| 109 | 109 | /** |
| 110 | 110 | * Handles store imports. |
| 111 | 111 | */ |
| 112 | - public function import_store( $key, $post_id, $data, $import_options, $_post ) { |
|
| 112 | + public function import_store($key, $post_id, $data, $import_options, $_post) { |
|
| 113 | 113 | |
| 114 | 114 | // Is the store class set? |
| 115 | - if ( ! isset( $this->datastores[ $key ] ) ) { |
|
| 115 | + if (!isset($this->datastores[$key])) { |
|
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /**@var GetPaid_Data */ |
| 120 | - $data_store = new $this->datastores[ $key ]( $post_id ); |
|
| 120 | + $data_store = new $this->datastores[$key]($post_id); |
|
| 121 | 121 | |
| 122 | 122 | // Abort if the invoice/item/discount does not exist. |
| 123 | - if ( ! $data_store->exists() ) { |
|
| 123 | + if (!$data_store->exists()) { |
|
| 124 | 124 | return; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // Prepare data props. |
| 128 | 128 | $prepared = array(); |
| 129 | 129 | |
| 130 | - foreach ( array_keys( $this->get_store_fields( $key ) ) as $field ) { |
|
| 130 | + foreach (array_keys($this->get_store_fields($key)) as $field) { |
|
| 131 | 131 | // Make sure the user has allowed this field to be updated. |
| 132 | - if ( empty( $_post['ID'] ) || $this->add_ons[ $key ]->can_update_meta( $field, $import_options ) ) { |
|
| 132 | + if (empty($_post['ID']) || $this->add_ons[$key]->can_update_meta($field, $import_options)) { |
|
| 133 | 133 | |
| 134 | 134 | // Update the custom field with the imported data. |
| 135 | - $prepared[ $field ] = $data[ $field ]; |
|
| 135 | + $prepared[$field] = $data[$field]; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Only update if we have something to update. |
| 140 | - if ( ! empty( $prepared ) ) { |
|
| 141 | - $data_store->set_props( $prepared ); |
|
| 140 | + if (!empty($prepared)) { |
|
| 141 | + $data_store->set_props($prepared); |
|
| 142 | 142 | $data_store->save(); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Represents a single email type. |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param string $id Email Type. |
| 33 | 33 | * @param mixed $object Optional. Associated object. |
| 34 | 34 | */ |
| 35 | - public function __construct( $id, $object = false ) { |
|
| 35 | + public function __construct($id, $object = false) { |
|
| 36 | 36 | $this->id = $id; |
| 37 | 37 | $this->object = $object; |
| 38 | 38 | } |
@@ -42,18 +42,18 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return mixed |
| 44 | 44 | */ |
| 45 | - public function get_option( $key ) { |
|
| 45 | + public function get_option($key) { |
|
| 46 | 46 | |
| 47 | 47 | $key = "email_{$this->id}_$key"; |
| 48 | - $value = wpinv_get_option( $key, null ); |
|
| 49 | - if ( is_null( $value ) ) { |
|
| 48 | + $value = wpinv_get_option($key, null); |
|
| 49 | + if (is_null($value)) { |
|
| 50 | 50 | $options = wpinv_get_emails(); |
| 51 | 51 | |
| 52 | - if ( ! isset( $options[ $this->id ] ) || ! isset( $options[ $this->id ][ $key ] ) ) { |
|
| 52 | + if (!isset($options[$this->id]) || !isset($options[$this->id][$key])) { |
|
| 53 | 53 | return ''; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $value = isset( $options[ $this->id ][ $key ]['std'] ) ? $options[ $this->id ][ $key ]['std'] : ''; |
|
| 56 | + $value = isset($options[$this->id][$key]['std']) ? $options[$this->id][$key]['std'] : ''; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return $value; |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | * @return string |
| 66 | 66 | */ |
| 67 | 67 | public function get_body() { |
| 68 | - $body = $this->get_option( 'body' ); |
|
| 69 | - return apply_filters( 'getpaid_get_email_body', $body, $this->id, $this->object ); |
|
| 68 | + $body = $this->get_option('body'); |
|
| 69 | + return apply_filters('getpaid_get_email_body', $body, $this->id, $this->object); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | 77 | public function get_subject() { |
| 78 | - $subject = $this->get_option( 'subject' ); |
|
| 79 | - return apply_filters( 'getpaid_get_email_subject', $subject, $this->id, $this->object ); |
|
| 78 | + $subject = $this->get_option('subject'); |
|
| 79 | + return apply_filters('getpaid_get_email_subject', $subject, $this->id, $this->object); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * @return string |
| 86 | 86 | */ |
| 87 | 87 | public function get_heading() { |
| 88 | - $heading = $this->get_option( 'heading' ); |
|
| 89 | - return apply_filters( 'getpaid_get_email_heading', $heading, $this->id, $this->object ); |
|
| 88 | + $heading = $this->get_option('heading'); |
|
| 89 | + return apply_filters('getpaid_get_email_heading', $heading, $this->id, $this->object); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | * @return bool |
| 96 | 96 | */ |
| 97 | 97 | public function is_active() { |
| 98 | - $is_active = ! empty( $this->get_option( 'active' ) ); |
|
| 99 | - return apply_filters( 'getpaid_email_type_is_active', $is_active, $this->id, $this->object ); |
|
| 98 | + $is_active = !empty($this->get_option('active')); |
|
| 99 | + return apply_filters('getpaid_email_type_is_active', $is_active, $this->id, $this->object); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * @return bool |
| 106 | 106 | */ |
| 107 | 107 | public function include_admin_bcc() { |
| 108 | - $include_admin_bcc = ! empty( $this->get_option( 'admin_bcc' ) ); |
|
| 109 | - return apply_filters( 'getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object ); |
|
| 108 | + $include_admin_bcc = !empty($this->get_option('admin_bcc')); |
|
| 109 | + return apply_filters('getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | * @return bool |
| 116 | 116 | */ |
| 117 | 117 | public function is_admin_email() { |
| 118 | - $is_admin_email = in_array( $this->id, array( 'new_invoice', 'failed_invoice' ) ); |
|
| 119 | - return apply_filters( 'getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object ); |
|
| 118 | + $is_admin_email = in_array($this->id, array('new_invoice', 'failed_invoice')); |
|
| 119 | + return apply_filters('getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @return array |
| 126 | 126 | */ |
| 127 | 127 | public function get_attachments() { |
| 128 | - return apply_filters( 'getpaid_get_email_attachments', array(), $this->id, $this->object ); |
|
| 128 | + return apply_filters('getpaid_get_email_attachments', array(), $this->id, $this->object); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $merge_tags = array( |
| 139 | 139 | '{site_title}' => wpinv_get_blogname(), |
| 140 | - '{date}' => getpaid_format_date_value( current_time( 'mysql' ) ), |
|
| 140 | + '{date}' => getpaid_format_date_value(current_time('mysql')), |
|
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - return apply_filters( 'getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id ); |
|
| 143 | + return apply_filters('getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | * @param array $merge_tags |
| 151 | 151 | * @return string |
| 152 | 152 | */ |
| 153 | - public function add_merge_tags( $text, $merge_tags = array() ) { |
|
| 153 | + public function add_merge_tags($text, $merge_tags = array()) { |
|
| 154 | 154 | |
| 155 | - foreach ( $merge_tags as $key => $value ) { |
|
| 156 | - $text = str_replace( $key, $value, $text ); |
|
| 155 | + foreach ($merge_tags as $key => $value) { |
|
| 156 | + $text = str_replace($key, $value, $text); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - return wptexturize( $text ); |
|
| 159 | + return wptexturize($text); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param array $extra_args Extra template args |
| 167 | 167 | * @return string |
| 168 | 168 | */ |
| 169 | - public function get_content( $merge_tags = array(), $extra_args = array() ) { |
|
| 169 | + public function get_content($merge_tags = array(), $extra_args = array()) { |
|
| 170 | 170 | |
| 171 | 171 | $content = wpinv_get_template_html( |
| 172 | 172 | "emails/wpinv-email-{$this->id}.php", |
@@ -176,15 +176,15 @@ discard block |
||
| 176 | 176 | 'invoice' => $this->object, // Backwards compat. |
| 177 | 177 | 'object' => $this->object, |
| 178 | 178 | 'email_type' => $this->id, |
| 179 | - 'email_heading' => $this->add_merge_tags( $this->get_heading(), $merge_tags ), |
|
| 179 | + 'email_heading' => $this->add_merge_tags($this->get_heading(), $merge_tags), |
|
| 180 | 180 | 'sent_to_admin' => $this->is_admin_email(), |
| 181 | 181 | 'plain_text' => false, |
| 182 | - 'message_body' => wpautop( $this->add_merge_tags( $this->get_body(), $merge_tags ) ), |
|
| 182 | + 'message_body' => wpautop($this->add_merge_tags($this->get_body(), $merge_tags)), |
|
| 183 | 183 | ) |
| 184 | 184 | ) |
| 185 | 185 | ); |
| 186 | 186 | |
| 187 | - return wpinv_email_style_body( $content ); |
|
| 187 | + return wpinv_email_style_body($content); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * GetPaid_Reports_Helper Class. |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param array $args |
| 27 | 27 | * @return mixed depending on query_type |
| 28 | 28 | */ |
| 29 | - public static function get_invoice_report_data( $args = array() ) { |
|
| 29 | + public static function get_invoice_report_data($args = array()) { |
|
| 30 | 30 | global $wpdb; |
| 31 | 31 | |
| 32 | 32 | $default_args = array( |
@@ -37,94 +37,94 @@ discard block |
||
| 37 | 37 | 'order_by' => '', // What to order by. |
| 38 | 38 | 'limit' => '', // Results limit. |
| 39 | 39 | 'filter_range' => array(), // An array of before and after dates to limit results by. |
| 40 | - 'invoice_types' => array( 'wpi_invoice' ), // An array of post types to retrieve. |
|
| 41 | - 'invoice_status' => array( 'publish', 'wpi-processing', 'wpi-onhold' ), |
|
| 40 | + 'invoice_types' => array('wpi_invoice'), // An array of post types to retrieve. |
|
| 41 | + 'invoice_status' => array('publish', 'wpi-processing', 'wpi-onhold'), |
|
| 42 | 42 | 'parent_invoice_status' => false, // Optionally filter by parent invoice status. |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | - $args = apply_filters( 'getpaid_reports_get_invoice_report_data_args', $args ); |
|
| 46 | - $args = wp_parse_args( $args, $default_args ); |
|
| 45 | + $args = apply_filters('getpaid_reports_get_invoice_report_data_args', $args); |
|
| 46 | + $args = wp_parse_args($args, $default_args); |
|
| 47 | 47 | |
| 48 | - extract( $args ); |
|
| 48 | + extract($args); |
|
| 49 | 49 | |
| 50 | - if ( empty( $data ) ) { |
|
| 50 | + if (empty($data)) { |
|
| 51 | 51 | return ''; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $query = array(); |
| 55 | - $query['select'] = 'SELECT ' . implode( ',', self::prepare_invoice_data( $data ) ); |
|
| 55 | + $query['select'] = 'SELECT ' . implode(',', self::prepare_invoice_data($data)); |
|
| 56 | 56 | $query['from'] = "FROM {$wpdb->posts} AS posts"; |
| 57 | - $query['join'] = implode( ' ', self::prepare_invoice_joins( $data + $where, ! empty( $parent_invoice_status ) ) ); |
|
| 57 | + $query['join'] = implode(' ', self::prepare_invoice_joins($data + $where, !empty($parent_invoice_status))); |
|
| 58 | 58 | |
| 59 | 59 | $query['where'] = " |
| 60 | - WHERE posts.post_type IN ( '" . implode( "','", $invoice_types ) . "' ) |
|
| 60 | + WHERE posts.post_type IN ( '" . implode("','", $invoice_types) . "' ) |
|
| 61 | 61 | "; |
| 62 | 62 | |
| 63 | - if ( ! empty( $invoice_status ) ) { |
|
| 63 | + if (!empty($invoice_status)) { |
|
| 64 | 64 | $query['where'] .= " |
| 65 | - AND posts.post_status IN ( '" . implode( "','", $invoice_status ) . "' ) |
|
| 65 | + AND posts.post_status IN ( '" . implode("','", $invoice_status) . "' ) |
|
| 66 | 66 | "; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ( ! empty( $parent_invoice_status ) ) { |
|
| 70 | - if ( ! empty( $invoice_status ) ) { |
|
| 71 | - $query['where'] .= " AND ( parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) OR parent.ID IS NULL ) "; |
|
| 69 | + if (!empty($parent_invoice_status)) { |
|
| 70 | + if (!empty($invoice_status)) { |
|
| 71 | + $query['where'] .= " AND ( parent.post_status IN ( '" . implode("','", $parent_invoice_status) . "' ) OR parent.ID IS NULL ) "; |
|
| 72 | 72 | } else { |
| 73 | - $query['where'] .= " AND parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) "; |
|
| 73 | + $query['where'] .= " AND parent.post_status IN ( '" . implode("','", $parent_invoice_status) . "' ) "; |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( ! empty( $filter_range['before'] ) ) { |
|
| 77 | + if (!empty($filter_range['before'])) { |
|
| 78 | 78 | $query['where'] .= " |
| 79 | - AND posts.post_date < '" . date( 'Y-m-d 23:59:59', strtotime( $filter_range['before'] ) ) . "' |
|
| 79 | + AND posts.post_date < '" . date('Y-m-d 23:59:59', strtotime($filter_range['before'])) . "' |
|
| 80 | 80 | "; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( ! empty( $filter_range['after'] ) ) { |
|
| 83 | + if (!empty($filter_range['after'])) { |
|
| 84 | 84 | $query['where'] .= " |
| 85 | - AND posts.post_date > '" . date( 'Y-m-d H:i:s', strtotime( $filter_range['after'] ) ) . "' |
|
| 85 | + AND posts.post_date > '" . date('Y-m-d H:i:s', strtotime($filter_range['after'])) . "' |
|
| 86 | 86 | "; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ( ! empty( $where ) ) { |
|
| 89 | + if (!empty($where)) { |
|
| 90 | 90 | |
| 91 | - foreach ( $where as $value ) { |
|
| 91 | + foreach ($where as $value) { |
|
| 92 | 92 | |
| 93 | - if ( strtolower( $value['operator'] ) == 'in' || strtolower( $value['operator'] ) == 'not in' ) { |
|
| 93 | + if (strtolower($value['operator']) == 'in' || strtolower($value['operator']) == 'not in') { |
|
| 94 | 94 | |
| 95 | - if ( is_array( $value['value'] ) ) { |
|
| 96 | - $value['value'] = implode( "','", $value['value'] ); |
|
| 95 | + if (is_array($value['value'])) { |
|
| 96 | + $value['value'] = implode("','", $value['value']); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( ! empty( $value['value'] ) ) { |
|
| 99 | + if (!empty($value['value'])) { |
|
| 100 | 100 | $where_value = "{$value['operator']} ('{$value['value']}')"; |
| 101 | 101 | } |
| 102 | 102 | } else { |
| 103 | 103 | $where_value = "{$value['operator']} '{$value['value']}'"; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ( ! empty( $where_value ) ) { |
|
| 106 | + if (!empty($where_value)) { |
|
| 107 | 107 | $query['where'] .= " AND {$value['key']} {$where_value}"; |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ( $group_by ) { |
|
| 112 | + if ($group_by) { |
|
| 113 | 113 | $query['group_by'] = "GROUP BY {$group_by}"; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if ( $order_by ) { |
|
| 116 | + if ($order_by) { |
|
| 117 | 117 | $query['order_by'] = "ORDER BY {$order_by}"; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if ( $limit ) { |
|
| 120 | + if ($limit) { |
|
| 121 | 121 | $query['limit'] = "LIMIT {$limit}"; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $query = apply_filters( 'getpaid_reports_get_invoice_report_query', $query, $data ); |
|
| 125 | - $query = implode( ' ', $query ); |
|
| 124 | + $query = apply_filters('getpaid_reports_get_invoice_report_query', $query, $data); |
|
| 125 | + $query = implode(' ', $query); |
|
| 126 | 126 | |
| 127 | - return self::execute( $query_type, $query ); |
|
| 127 | + return self::execute($query_type, $query); |
|
| 128 | 128 | |
| 129 | 129 | } |
| 130 | 130 | |
@@ -135,26 +135,26 @@ discard block |
||
| 135 | 135 | * @param array $data |
| 136 | 136 | * @return array |
| 137 | 137 | */ |
| 138 | - public static function prepare_invoice_data( $data ) { |
|
| 138 | + public static function prepare_invoice_data($data) { |
|
| 139 | 139 | |
| 140 | 140 | $prepared = array(); |
| 141 | 141 | |
| 142 | - foreach ( $data as $raw_key => $value ) { |
|
| 143 | - $key = sanitize_key( $raw_key ); |
|
| 142 | + foreach ($data as $raw_key => $value) { |
|
| 143 | + $key = sanitize_key($raw_key); |
|
| 144 | 144 | $distinct = ''; |
| 145 | 145 | |
| 146 | - if ( isset( $value['distinct'] ) ) { |
|
| 146 | + if (isset($value['distinct'])) { |
|
| 147 | 147 | $distinct = 'DISTINCT'; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $get_key = self::get_invoice_table_key( $key, $value['type'] ); |
|
| 150 | + $get_key = self::get_invoice_table_key($key, $value['type']); |
|
| 151 | 151 | |
| 152 | - if ( false === $get_key ) { |
|
| 152 | + if (false === $get_key) { |
|
| 153 | 153 | // Skip to the next foreach iteration else the query will be invalid. |
| 154 | 154 | continue; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ( ! empty( $value['function'] ) ) { |
|
| 157 | + if (!empty($value['function'])) { |
|
| 158 | 158 | $get = "{$value['function']}({$distinct} {$get_key})"; |
| 159 | 159 | } else { |
| 160 | 160 | $get = "{$distinct} {$get_key}"; |
@@ -175,22 +175,22 @@ discard block |
||
| 175 | 175 | * @param bool $with_parent |
| 176 | 176 | * @return array |
| 177 | 177 | */ |
| 178 | - public static function prepare_invoice_joins( $data, $with_parent ) { |
|
| 178 | + public static function prepare_invoice_joins($data, $with_parent) { |
|
| 179 | 179 | global $wpdb; |
| 180 | 180 | |
| 181 | 181 | $prepared = array(); |
| 182 | 182 | |
| 183 | - foreach ( $data as $raw_key => $value ) { |
|
| 184 | - $join_type = isset( $value['join_type'] ) ? $value['join_type'] : 'INNER'; |
|
| 185 | - $type = isset( $value['type'] ) ? $value['type'] : false; |
|
| 186 | - $key = sanitize_key( $raw_key ); |
|
| 183 | + foreach ($data as $raw_key => $value) { |
|
| 184 | + $join_type = isset($value['join_type']) ? $value['join_type'] : 'INNER'; |
|
| 185 | + $type = isset($value['type']) ? $value['type'] : false; |
|
| 186 | + $key = sanitize_key($raw_key); |
|
| 187 | 187 | |
| 188 | - switch ( $type ) { |
|
| 188 | + switch ($type) { |
|
| 189 | 189 | case 'meta': |
| 190 | - $prepared[ "meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON ( posts.ID = meta_{$key}.post_id AND meta_{$key}.meta_key = '{$raw_key}' )"; |
|
| 190 | + $prepared["meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON ( posts.ID = meta_{$key}.post_id AND meta_{$key}.meta_key = '{$raw_key}' )"; |
|
| 191 | 191 | break; |
| 192 | 192 | case 'parent_meta': |
| 193 | - $prepared[ "parent_meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS parent_meta_{$key} ON (posts.post_parent = parent_meta_{$key}.post_id) AND (parent_meta_{$key}.meta_key = '{$raw_key}')"; |
|
| 193 | + $prepared["parent_meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS parent_meta_{$key} ON (posts.post_parent = parent_meta_{$key}.post_id) AND (parent_meta_{$key}.meta_key = '{$raw_key}')"; |
|
| 194 | 194 | break; |
| 195 | 195 | case 'invoice_data': |
| 196 | 196 | $prepared['invoices'] = "{$join_type} JOIN {$wpdb->prefix}getpaid_invoices AS invoices ON posts.ID = invoices.post_id"; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if ( $with_parent ) { |
|
| 204 | + if ($with_parent) { |
|
| 205 | 205 | $prepared['parent'] = "LEFT JOIN {$wpdb->posts} AS parent ON posts.post_parent = parent.ID"; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param string $table |
| 218 | 218 | * @return string|false |
| 219 | 219 | */ |
| 220 | - public static function get_invoice_table_key( $key, $table ) { |
|
| 220 | + public static function get_invoice_table_key($key, $table) { |
|
| 221 | 221 | |
| 222 | 222 | $keys = array( |
| 223 | 223 | 'meta' => "meta_{$key}.meta_value", |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | 'invoice_item' => "invoice_items.{$key}", |
| 228 | 228 | ); |
| 229 | 229 | |
| 230 | - return isset( $keys[ $table ] ) ? $keys[ $table ] : false; |
|
| 230 | + return isset($keys[$table]) ? $keys[$table] : false; |
|
| 231 | 231 | |
| 232 | 232 | } |
| 233 | 233 | |
@@ -239,16 +239,16 @@ discard block |
||
| 239 | 239 | * @param string $query |
| 240 | 240 | * @return mixed depending on query_type |
| 241 | 241 | */ |
| 242 | - public static function execute( $query_type, $query ) { |
|
| 242 | + public static function execute($query_type, $query) { |
|
| 243 | 243 | global $wpdb; |
| 244 | 244 | |
| 245 | - $query_hash = md5( $query_type . $query ); |
|
| 246 | - $result = self::get_cached_query( $query_hash ); |
|
| 247 | - if ( $result === false ) { |
|
| 245 | + $query_hash = md5($query_type . $query); |
|
| 246 | + $result = self::get_cached_query($query_hash); |
|
| 247 | + if ($result === false) { |
|
| 248 | 248 | self::enable_big_selects(); |
| 249 | 249 | |
| 250 | - $result = $wpdb->$query_type( $query ); |
|
| 251 | - self::set_cached_query( $query_hash, $result ); |
|
| 250 | + $result = $wpdb->$query_type($query); |
|
| 251 | + self::set_cached_query($query_hash, $result); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $result; |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | global $wpdb; |
| 265 | 265 | |
| 266 | - if ( ! $big_selects ) { |
|
| 267 | - $wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' ); |
|
| 266 | + if (!$big_selects) { |
|
| 267 | + $wpdb->query('SET SESSION SQL_BIG_SELECTS=1'); |
|
| 268 | 268 | $big_selects = true; |
| 269 | 269 | } |
| 270 | 270 | } |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return mixed|false The cache contents on success, false on failure to retrieve contents. |
| 278 | 278 | */ |
| 279 | - protected static function get_cached_query( $query_hash ) { |
|
| 279 | + protected static function get_cached_query($query_hash) { |
|
| 280 | 280 | |
| 281 | 281 | return wp_cache_get( |
| 282 | 282 | $query_hash, |
| 283 | - strtolower( __CLASS__ ) |
|
| 283 | + strtolower(__CLASS__) |
|
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | 286 | } |
@@ -291,12 +291,12 @@ discard block |
||
| 291 | 291 | * @param string $query_hash The query hash. |
| 292 | 292 | * @param mixed $data The data to cache. |
| 293 | 293 | */ |
| 294 | - protected static function set_cached_query( $query_hash, $data ) { |
|
| 294 | + protected static function set_cached_query($query_hash, $data) { |
|
| 295 | 295 | |
| 296 | 296 | wp_cache_set( |
| 297 | 297 | $query_hash, |
| 298 | 298 | $data, |
| 299 | - strtolower( __CLASS__ ), |
|
| 299 | + strtolower(__CLASS__), |
|
| 300 | 300 | MINUTE_IN_SECONDS |
| 301 | 301 | ); |
| 302 | 302 | |
@@ -7,20 +7,20 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Fetch the invoice. |
| 13 | -if ( empty( $invoice ) ) { |
|
| 14 | - $invoice = new WPInv_Invoice( $GLOBALS['post'] ); |
|
| 13 | +if (empty($invoice)) { |
|
| 14 | + $invoice = new WPInv_Invoice($GLOBALS['post']); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Abort if it does not exist. |
| 18 | -if ( $invoice->get_id() == 0 ) { |
|
| 18 | +if ($invoice->get_id() == 0) { |
|
| 19 | 19 | exit; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // Fires before printing an invoice. |
| 23 | -do_action( 'wpinv_invoice_print_before_display', $invoice ); |
|
| 23 | +do_action('wpinv_invoice_print_before_display', $invoice); |
|
| 24 | 24 | |
| 25 | 25 | ?><!DOCTYPE html> |
| 26 | 26 | |
@@ -29,16 +29,16 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | <head> |
| 31 | 31 | |
| 32 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
| 32 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
| 33 | 33 | <meta name="viewport" content="width=device-width, initial-scale=1.0" > |
| 34 | 34 | |
| 35 | 35 | <meta name="robots" content="noindex,nofollow"> |
| 36 | 36 | |
| 37 | 37 | <link rel="profile" href="https://gmpg.org/xfn/11"> |
| 38 | 38 | |
| 39 | - <title>#<?php echo esc_html( $invoice->get_number() ); ?></title> |
|
| 39 | + <title>#<?php echo esc_html($invoice->get_number()); ?></title> |
|
| 40 | 40 | |
| 41 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
| 41 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
| 42 | 42 | |
| 43 | 43 | <style type="text/css"> |
| 44 | 44 | .body{ |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | <body class="body wpinv wpinv-print" style="font-weight: 400;"> |
| 71 | 71 | |
| 72 | 72 | <div id="wpinv-print-inner"> |
| 73 | - <?php do_action( 'getpaid_invoice', $invoice ); ?> |
|
| 74 | - <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?> |
|
| 73 | + <?php do_action('getpaid_invoice', $invoice); ?> |
|
| 74 | + <?php do_action('wpinv_invoice_print_body_end', $invoice); ?> |
|
| 75 | 75 | </div> |
| 76 | 76 | </body> |
| 77 | 77 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | +if (!defined('ABSPATH')) { |
|
| 4 | 4 | exit; // Exit if accessed directly |
| 5 | 5 | } |
| 6 | 6 | |
@@ -19,12 +19,12 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return string |
| 21 | 21 | */ |
| 22 | - public static function name( $text, $multiple = false ) { |
|
| 22 | + public static function name($text, $multiple = false) { |
|
| 23 | 23 | $output = ''; |
| 24 | 24 | |
| 25 | - if ( $text ) { |
|
| 26 | - $is_multiple = strpos( $text, '[' ) === false && $multiple ? '[]' : ''; |
|
| 27 | - $output = ' name="' . esc_attr( $text ) . $is_multiple . '" '; |
|
| 25 | + if ($text) { |
|
| 26 | + $is_multiple = strpos($text, '[') === false && $multiple ? '[]' : ''; |
|
| 27 | + $output = ' name="' . esc_attr($text) . $is_multiple . '" '; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | return $output; |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return string The sanitized item. |
| 39 | 39 | */ |
| 40 | - public static function id( $text ) { |
|
| 40 | + public static function id($text) { |
|
| 41 | 41 | $output = ''; |
| 42 | 42 | |
| 43 | - if ( $text ) { |
|
| 44 | - $output = ' id="' . sanitize_html_class( $text ) . '" '; |
|
| 43 | + if ($text) { |
|
| 44 | + $output = ' id="' . sanitize_html_class($text) . '" '; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | return $output; |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return string The sanitized item. |
| 56 | 56 | */ |
| 57 | - public static function title( $text ) { |
|
| 57 | + public static function title($text) { |
|
| 58 | 58 | $output = ''; |
| 59 | 59 | |
| 60 | - if ( $text ) { |
|
| 61 | - $output = ' title="' . esc_attr( $text ) . '" '; |
|
| 60 | + if ($text) { |
|
| 61 | + $output = ' title="' . esc_attr($text) . '" '; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | return $output; |
@@ -71,11 +71,11 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @return string The sanitized item. |
| 73 | 73 | */ |
| 74 | - public static function value( $text ) { |
|
| 74 | + public static function value($text) { |
|
| 75 | 75 | $output = ''; |
| 76 | 76 | |
| 77 | - if ( $text !== null && $text !== false ) { |
|
| 78 | - $output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" '; |
|
| 77 | + if ($text !== null && $text !== false) { |
|
| 78 | + $output = ' value="' . esc_attr(wp_unslash($text)) . '" '; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | return $output; |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string The sanitized item. |
| 90 | 90 | */ |
| 91 | - public static function class_attr( $text ) { |
|
| 91 | + public static function class_attr($text) { |
|
| 92 | 92 | $output = ''; |
| 93 | 93 | |
| 94 | - if ( $text ) { |
|
| 95 | - $classes = self::esc_classes( $text ); |
|
| 96 | - if ( ! empty( $classes ) ) { |
|
| 94 | + if ($text) { |
|
| 95 | + $classes = self::esc_classes($text); |
|
| 96 | + if (!empty($classes)) { |
|
| 97 | 97 | $output = ' class="' . $classes . '" '; |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -108,15 +108,15 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | - public static function esc_classes( $text ) { |
|
| 111 | + public static function esc_classes($text) { |
|
| 112 | 112 | $output = ''; |
| 113 | 113 | |
| 114 | - if ( $text ) { |
|
| 115 | - $classes = explode( " ", $text ); |
|
| 116 | - $classes = array_map( "trim", $classes ); |
|
| 117 | - $classes = array_map( "sanitize_html_class", $classes ); |
|
| 118 | - if ( ! empty( $classes ) ) { |
|
| 119 | - $output = implode( " ", $classes ); |
|
| 114 | + if ($text) { |
|
| 115 | + $classes = explode(" ", $text); |
|
| 116 | + $classes = array_map("trim", $classes); |
|
| 117 | + $classes = array_map("sanitize_html_class", $classes); |
|
| 118 | + if (!empty($classes)) { |
|
| 119 | + $output = implode(" ", $classes); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | - public static function data_attributes( $args ) { |
|
| 132 | + public static function data_attributes($args) { |
|
| 133 | 133 | $output = ''; |
| 134 | 134 | |
| 135 | - if ( ! empty( $args ) ) { |
|
| 135 | + if (!empty($args)) { |
|
| 136 | 136 | |
| 137 | - foreach ( $args as $key => $val ) { |
|
| 138 | - if ( substr( $key, 0, 5 ) === "data-" ) { |
|
| 139 | - $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" '; |
|
| 137 | + foreach ($args as $key => $val) { |
|
| 138 | + if (substr($key, 0, 5) === "data-") { |
|
| 139 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return string |
| 151 | 151 | */ |
| 152 | - public static function aria_attributes( $args ) { |
|
| 152 | + public static function aria_attributes($args) { |
|
| 153 | 153 | $output = ''; |
| 154 | 154 | |
| 155 | - if ( ! empty( $args ) ) { |
|
| 155 | + if (!empty($args)) { |
|
| 156 | 156 | |
| 157 | - foreach ( $args as $key => $val ) { |
|
| 158 | - if ( substr( $key, 0, 5 ) === "aria-" ) { |
|
| 159 | - $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" '; |
|
| 157 | + foreach ($args as $key => $val) { |
|
| 158 | + if (substr($key, 0, 5) === "aria-") { |
|
| 159 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -173,19 +173,19 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @return string |
| 175 | 175 | */ |
| 176 | - public static function icon( $class, $space_after = false, $extra_attributes = array() ) { |
|
| 176 | + public static function icon($class, $space_after = false, $extra_attributes = array()) { |
|
| 177 | 177 | $output = ''; |
| 178 | 178 | |
| 179 | - if ( $class ) { |
|
| 180 | - $classes = self::esc_classes( $class ); |
|
| 181 | - if ( ! empty( $classes ) ) { |
|
| 179 | + if ($class) { |
|
| 180 | + $classes = self::esc_classes($class); |
|
| 181 | + if (!empty($classes)) { |
|
| 182 | 182 | $output = '<i class="' . $classes . '" '; |
| 183 | 183 | // extra attributes |
| 184 | - if ( ! empty( $extra_attributes ) ) { |
|
| 185 | - $output .= AUI_Component_Helper::extra_attributes( $extra_attributes ); |
|
| 184 | + if (!empty($extra_attributes)) { |
|
| 185 | + $output .= AUI_Component_Helper::extra_attributes($extra_attributes); |
|
| 186 | 186 | } |
| 187 | 187 | $output .= '></i>'; |
| 188 | - if ( $space_after ) { |
|
| 188 | + if ($space_after) { |
|
| 189 | 189 | $output .= " "; |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -199,14 +199,14 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return string |
| 201 | 201 | */ |
| 202 | - public static function extra_attributes( $args ) { |
|
| 202 | + public static function extra_attributes($args) { |
|
| 203 | 203 | $output = ''; |
| 204 | 204 | |
| 205 | - if ( ! empty( $args ) ) { |
|
| 205 | + if (!empty($args)) { |
|
| 206 | 206 | |
| 207 | - if ( is_array( $args ) ) { |
|
| 208 | - foreach ( $args as $key => $val ) { |
|
| 209 | - $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" '; |
|
| 207 | + if (is_array($args)) { |
|
| 208 | + foreach ($args as $key => $val) { |
|
| 209 | + $output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" '; |
|
| 210 | 210 | } |
| 211 | 211 | } else { |
| 212 | 212 | $output .= ' ' . $args . ' '; |
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return string |
| 224 | 224 | */ |
| 225 | - public static function help_text( $text ) { |
|
| 225 | + public static function help_text($text) { |
|
| 226 | 226 | $output = ''; |
| 227 | 227 | |
| 228 | - if ( $text ) { |
|
| 229 | - $output .= '<small class="form-text text-muted">' . wp_kses_post( $text ) . '</small>'; |
|
| 228 | + if ($text) { |
|
| 229 | + $output .= '<small class="form-text text-muted">' . wp_kses_post($text) . '</small>'; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | |
@@ -240,17 +240,17 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return string|void |
| 242 | 242 | */ |
| 243 | - public static function element_require( $input ) { |
|
| 243 | + public static function element_require($input) { |
|
| 244 | 244 | |
| 245 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 245 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
| 246 | 246 | |
| 247 | - $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( |
|
| 247 | + $output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array( |
|
| 248 | 248 | "jQuery(form).find('[data-argument=\"", |
| 249 | 249 | "\"]').find('input,select,textarea').val()", |
| 250 | 250 | "\"]').find('input:checked').val()", |
| 251 | - ), $input ) ); |
|
| 251 | + ), $input)); |
|
| 252 | 252 | |
| 253 | - if ( $output ) { |
|
| 253 | + if ($output) { |
|
| 254 | 254 | $output = ' data-element-require="' . $output . '" '; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -267,21 +267,21 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @return mixed Stripped value. |
| 269 | 269 | */ |
| 270 | - public static function sanitize_html_field( $value, $input = array() ) { |
|
| 270 | + public static function sanitize_html_field($value, $input = array()) { |
|
| 271 | 271 | $original = $value; |
| 272 | 272 | |
| 273 | - if ( is_array( $value ) ) { |
|
| 274 | - foreach ( $value as $index => $item ) { |
|
| 275 | - $value[ $index ] = self::_sanitize_html_field( $value, $input ); |
|
| 273 | + if (is_array($value)) { |
|
| 274 | + foreach ($value as $index => $item) { |
|
| 275 | + $value[$index] = self::_sanitize_html_field($value, $input); |
|
| 276 | 276 | } |
| 277 | - } elseif ( is_object( $value ) ) { |
|
| 278 | - $object_vars = get_object_vars( $value ); |
|
| 277 | + } elseif (is_object($value)) { |
|
| 278 | + $object_vars = get_object_vars($value); |
|
| 279 | 279 | |
| 280 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
| 281 | - $value->$property_name = self::_sanitize_html_field( $property_value, $input ); |
|
| 280 | + foreach ($object_vars as $property_name => $property_value) { |
|
| 281 | + $value->$property_name = self::_sanitize_html_field($property_value, $input); |
|
| 282 | 282 | } |
| 283 | 283 | } else { |
| 284 | - $value = self::_sanitize_html_field( $value, $input ); |
|
| 284 | + $value = self::_sanitize_html_field($value, $input); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * @param string|array $value Original content without filter. |
| 294 | 294 | * @param array $input Input Field. |
| 295 | 295 | */ |
| 296 | - return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input ); |
|
| 296 | + return apply_filters('ayecode_ui_sanitize_html_field', $value, $original, $input); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -316,20 +316,20 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @return string Filtered content with only allowed HTML elements. |
| 318 | 318 | */ |
| 319 | - public static function _sanitize_html_field( $value, $input = array() ) { |
|
| 320 | - if ( $value === '' ) { |
|
| 319 | + public static function _sanitize_html_field($value, $input = array()) { |
|
| 320 | + if ($value === '') { |
|
| 321 | 321 | return $value; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $allowed_html = self::kses_allowed_html( 'post', $input ); |
|
| 324 | + $allowed_html = self::kses_allowed_html('post', $input); |
|
| 325 | 325 | |
| 326 | - if ( ! is_array( $allowed_html ) ) { |
|
| 327 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
| 326 | + if (!is_array($allowed_html)) { |
|
| 327 | + $allowed_html = wp_kses_allowed_html('post'); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - $filtered = trim( wp_unslash( $value ) ); |
|
| 331 | - $filtered = wp_kses( $filtered, $allowed_html ); |
|
| 332 | - $filtered = balanceTags( $filtered ); // Balances tags |
|
| 330 | + $filtered = trim(wp_unslash($value)); |
|
| 331 | + $filtered = wp_kses($filtered, $allowed_html); |
|
| 332 | + $filtered = balanceTags($filtered); // Balances tags |
|
| 333 | 333 | |
| 334 | 334 | return $filtered; |
| 335 | 335 | } |
@@ -346,12 +346,12 @@ discard block |
||
| 346 | 346 | * |
| 347 | 347 | * @return array Array of allowed HTML tags and their allowed attributes. |
| 348 | 348 | */ |
| 349 | - public static function kses_allowed_html( $context = 'post', $input = array() ) { |
|
| 350 | - $allowed_html = wp_kses_allowed_html( $context ); |
|
| 349 | + public static function kses_allowed_html($context = 'post', $input = array()) { |
|
| 350 | + $allowed_html = wp_kses_allowed_html($context); |
|
| 351 | 351 | |
| 352 | - if ( is_array( $allowed_html ) ) { |
|
| 352 | + if (is_array($allowed_html)) { |
|
| 353 | 353 | // <iframe> |
| 354 | - if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) { |
|
| 354 | + if (!isset($allowed_html['iframe']) && $context == 'post') { |
|
| 355 | 355 | $allowed_html['iframe'] = array( |
| 356 | 356 | 'class' => true, |
| 357 | 357 | 'id' => true, |
@@ -380,23 +380,23 @@ discard block |
||
| 380 | 380 | * @param @param string|array $context The context for which to retrieve tags. |
| 381 | 381 | * @param array $input Input field. |
| 382 | 382 | */ |
| 383 | - return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input ); |
|
| 383 | + return apply_filters('ayecode_ui_kses_allowed_html', $allowed_html, $context, $input); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - public static function get_column_class( $label_number = 2, $type = 'label' ) { |
|
| 386 | + public static function get_column_class($label_number = 2, $type = 'label') { |
|
| 387 | 387 | |
| 388 | 388 | $class = ''; |
| 389 | 389 | |
| 390 | 390 | // set default if empty |
| 391 | - if( $label_number === '' ){ |
|
| 391 | + if ($label_number === '') { |
|
| 392 | 392 | $label_number = 2; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - if ( $label_number && $label_number < 12 && $label_number > 0 ) { |
|
| 396 | - if ( $type == 'label' ) { |
|
| 397 | - $class = 'col-sm-' . absint( $label_number ); |
|
| 398 | - } elseif ( $type == 'input' ) { |
|
| 399 | - $class = 'col-sm-' . ( 12 - absint( $label_number ) ); |
|
| 395 | + if ($label_number && $label_number < 12 && $label_number > 0) { |
|
| 396 | + if ($type == 'label') { |
|
| 397 | + $class = 'col-sm-' . absint($label_number); |
|
| 398 | + } elseif ($type == 'input') { |
|
| 399 | + $class = 'col-sm-' . (12 - absint($label_number)); |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | * @param string $str String to sanitize. |
| 416 | 416 | * @return string Sanitized string. |
| 417 | 417 | */ |
| 418 | - public static function sanitize_textarea_field( $str ) { |
|
| 419 | - $filtered = self::_sanitize_text_fields( $str, true ); |
|
| 418 | + public static function sanitize_textarea_field($str) { |
|
| 419 | + $filtered = self::_sanitize_text_fields($str, true); |
|
| 420 | 420 | |
| 421 | 421 | /** |
| 422 | 422 | * Filters a sanitized textarea field string. |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * @param string $filtered The sanitized string. |
| 427 | 427 | * @param string $str The string prior to being sanitized. |
| 428 | 428 | */ |
| 429 | - return apply_filters( 'sanitize_textarea_field', $filtered, $str ); |
|
| 429 | + return apply_filters('sanitize_textarea_field', $filtered, $str); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -439,40 +439,40 @@ discard block |
||
| 439 | 439 | * @param bool $keep_newlines Optional. Whether to keep newlines. Default: false. |
| 440 | 440 | * @return string Sanitized string. |
| 441 | 441 | */ |
| 442 | - public static function _sanitize_text_fields( $str, $keep_newlines = false ) { |
|
| 443 | - if ( is_object( $str ) || is_array( $str ) ) { |
|
| 442 | + public static function _sanitize_text_fields($str, $keep_newlines = false) { |
|
| 443 | + if (is_object($str) || is_array($str)) { |
|
| 444 | 444 | return ''; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | $str = (string) $str; |
| 448 | 448 | |
| 449 | - $filtered = wp_check_invalid_utf8( $str ); |
|
| 449 | + $filtered = wp_check_invalid_utf8($str); |
|
| 450 | 450 | |
| 451 | - if ( strpos( $filtered, '<' ) !== false ) { |
|
| 452 | - $filtered = wp_pre_kses_less_than( $filtered ); |
|
| 451 | + if (strpos($filtered, '<') !== false) { |
|
| 452 | + $filtered = wp_pre_kses_less_than($filtered); |
|
| 453 | 453 | // This will strip extra whitespace for us. |
| 454 | - $filtered = wp_strip_all_tags( $filtered, false ); |
|
| 454 | + $filtered = wp_strip_all_tags($filtered, false); |
|
| 455 | 455 | |
| 456 | 456 | // Use HTML entities in a special case to make sure no later |
| 457 | 457 | // newline stripping stage could lead to a functional tag. |
| 458 | - $filtered = str_replace( "<\n", "<\n", $filtered ); |
|
| 458 | + $filtered = str_replace("<\n", "<\n", $filtered); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - if ( ! $keep_newlines ) { |
|
| 462 | - $filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered ); |
|
| 461 | + if (!$keep_newlines) { |
|
| 462 | + $filtered = preg_replace('/[\r\n\t ]+/', ' ', $filtered); |
|
| 463 | 463 | } |
| 464 | - $filtered = trim( $filtered ); |
|
| 464 | + $filtered = trim($filtered); |
|
| 465 | 465 | |
| 466 | 466 | $found = false; |
| 467 | - while ( preg_match( '`[^%](%[a-f0-9]{2})`i', $filtered, $match ) ) { |
|
| 468 | - $filtered = str_replace( $match[1], '', $filtered ); |
|
| 467 | + while (preg_match('`[^%](%[a-f0-9]{2})`i', $filtered, $match)) { |
|
| 468 | + $filtered = str_replace($match[1], '', $filtered); |
|
| 469 | 469 | $found = true; |
| 470 | 470 | } |
| 471 | - unset( $match ); |
|
| 471 | + unset($match); |
|
| 472 | 472 | |
| 473 | - if ( $found ) { |
|
| 473 | + if ($found) { |
|
| 474 | 474 | // Strip out the whitespace that may now exist after removing the octets. |
| 475 | - $filtered = trim( preg_replace( '` +`', ' ', $filtered ) ); |
|
| 475 | + $filtered = trim(preg_replace('` +`', ' ', $filtered)); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | return $filtered; |