@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class WPInv_Plugin { |
| 15 | 15 | private static $instance; |
| 16 | 16 | |
| 17 | 17 | public static function run() { |
| 18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
| 18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
| 19 | 19 | self::$instance = new WPInv_Plugin; |
| 20 | 20 | self::$instance->includes(); |
| 21 | 21 | self::$instance->actions(); |
@@ -32,33 +32,33 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function define_constants() { |
| 35 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
| 36 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
| 35 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
| 36 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | private function actions() { |
| 40 | 40 | /* Internationalize the text strings used. */ |
| 41 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
| 41 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
| 42 | 42 | |
| 43 | 43 | /* Perform actions on admin initialization. */ |
| 44 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
| 45 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
| 46 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
| 44 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
| 45 | + add_action('init', array(&$this, 'init'), 3); |
|
| 46 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
| 47 | 47 | |
| 48 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 49 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 48 | + if (class_exists('BuddyPress')) { |
|
| 49 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 53 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
| 52 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
| 53 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
| 54 | 54 | |
| 55 | - if ( is_admin() ) { |
|
| 56 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
| 57 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
| 58 | - add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) ); |
|
| 55 | + if (is_admin()) { |
|
| 56 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
| 57 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
| 58 | + add_action('admin_init', array(&$this, 'init_ayecode_connect_helper')); |
|
| 59 | 59 | |
| 60 | 60 | } else { |
| 61 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 61 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,28 +68,28 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
| 70 | 70 | */ |
| 71 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
| 71 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
| 72 | 72 | |
| 73 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
| 73 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Maybe show the AyeCode Connect Notice. |
| 78 | 78 | */ |
| 79 | - public function init_ayecode_connect_helper(){ |
|
| 79 | + public function init_ayecode_connect_helper() { |
|
| 80 | 80 | // AyeCode Connect notice |
| 81 | - if ( is_admin() ){ |
|
| 81 | + if (is_admin()) { |
|
| 82 | 82 | // set the strings so they can be translated |
| 83 | 83 | $strings = array( |
| 84 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 85 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 86 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 87 | - 'connect_button' => __("Connect Site","invoicing"), |
|
| 88 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
| 89 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 90 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 84 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
| 85 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
| 86 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
| 87 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
| 88 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
| 89 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
| 90 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
| 91 | 91 | ); |
| 92 | - new AyeCode_Connect_Helper($strings,array('wpi-addons')); |
|
| 92 | + new AyeCode_Connect_Helper($strings, array('wpi-addons')); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | /* Internationalize the text strings used. */ |
| 98 | 98 | $this->load_textdomain(); |
| 99 | 99 | |
| 100 | - do_action( 'wpinv_loaded' ); |
|
| 100 | + do_action('wpinv_loaded'); |
|
| 101 | 101 | |
| 102 | 102 | // Fix oxygen page builder conflict |
| 103 | - if ( function_exists( 'ct_css_output' ) ) { |
|
| 103 | + if (function_exists('ct_css_output')) { |
|
| 104 | 104 | wpinv_oxygen_fix_conflict(); |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -110,229 +110,229 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @since 1.0 |
| 112 | 112 | */ |
| 113 | - public function load_textdomain( $locale = NULL ) { |
|
| 114 | - if ( empty( $locale ) ) { |
|
| 115 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 113 | + public function load_textdomain($locale = NULL) { |
|
| 114 | + if (empty($locale)) { |
|
| 115 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
| 118 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
| 119 | 119 | |
| 120 | - unload_textdomain( 'invoicing' ); |
|
| 121 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 122 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 120 | + unload_textdomain('invoicing'); |
|
| 121 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
| 122 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * Define language constants. |
| 126 | 126 | */ |
| 127 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 127 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | public function includes() { |
| 131 | 131 | global $wpinv_options; |
| 132 | 132 | |
| 133 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 133 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
| 134 | 134 | $wpinv_options = wpinv_get_settings(); |
| 135 | 135 | |
| 136 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
| 137 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 138 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 139 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 140 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 141 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 142 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 143 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
| 144 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 145 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 146 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 147 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 148 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 149 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
| 150 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
| 151 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
| 152 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' ); |
|
| 153 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
| 154 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
| 155 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
| 156 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
| 157 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 158 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 159 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
| 160 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
| 161 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
| 162 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
| 163 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
| 164 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
| 165 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
| 166 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
| 167 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
| 168 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
| 169 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
| 170 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
| 171 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 172 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 173 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 174 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 175 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 176 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
| 177 | - |
|
| 178 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
| 179 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 136 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
| 137 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
| 138 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
| 139 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
| 140 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
| 141 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
| 142 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
| 143 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
| 144 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
| 145 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
| 146 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
| 147 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
| 148 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
| 149 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
| 150 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
| 151 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
| 152 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php'); |
|
| 153 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
| 154 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
| 155 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
| 156 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
| 157 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
| 158 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
| 159 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
| 160 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
| 161 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
| 162 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
| 163 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
| 164 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
| 165 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
| 166 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
| 167 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
| 168 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
| 169 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
| 170 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
| 171 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
| 172 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
| 173 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
| 174 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
| 175 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
| 176 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
| 177 | + |
|
| 178 | + if (!class_exists('WPInv_EUVat')) { |
|
| 179 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 183 | - if ( !empty( $gateways ) ) { |
|
| 184 | - foreach ( $gateways as $gateway ) { |
|
| 185 | - if ( $gateway == 'manual' ) { |
|
| 182 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 183 | + if (!empty($gateways)) { |
|
| 184 | + foreach ($gateways as $gateway) { |
|
| 185 | + if ($gateway == 'manual') { |
|
| 186 | 186 | continue; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
| 190 | 190 | |
| 191 | - if ( file_exists( $gateway_file ) ) { |
|
| 192 | - require_once( $gateway_file ); |
|
| 191 | + if (file_exists($gateway_file)) { |
|
| 192 | + require_once($gateway_file); |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
| 196 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
| 197 | 197 | |
| 198 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 199 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 200 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 201 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
| 198 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 199 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
| 200 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
| 201 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
| 202 | 202 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
| 203 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
| 204 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
| 205 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 206 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
| 207 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 208 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
| 209 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 203 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
| 204 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
| 205 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
| 206 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
| 207 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
| 208 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
| 209 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
| 210 | 210 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
| 211 | 211 | // load the user class only on the users.php page |
| 212 | 212 | global $pagenow; |
| 213 | - if($pagenow=='users.php'){ |
|
| 213 | + if ($pagenow == 'users.php') { |
|
| 214 | 214 | new WPInv_Admin_Users(); |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Register cli commands |
| 219 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
| 221 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
| 219 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 220 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
| 221 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // include css inliner |
| 225 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
| 226 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
| 225 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
| 226 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 229 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | public function init() { |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | public function admin_init() { |
| 236 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
| 236 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | public function activation_redirect() { |
| 240 | 240 | // Bail if no activation redirect |
| 241 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
| 241 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
| 242 | 242 | return; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // Delete the redirect transient |
| 246 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 246 | + delete_transient('_wpinv_activation_redirect'); |
|
| 247 | 247 | |
| 248 | 248 | // Bail if activating from network, or bulk |
| 249 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 249 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 250 | 250 | return; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 253 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
| 254 | 254 | exit; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | public function enqueue_scripts() { |
| 258 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 258 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 259 | 259 | |
| 260 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
| 261 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 260 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
| 261 | + wp_enqueue_style('wpinv_front_style'); |
|
| 262 | 262 | |
| 263 | 263 | // Register scripts |
| 264 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 265 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 264 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 265 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION); |
|
| 266 | 266 | |
| 267 | 267 | $localize = array(); |
| 268 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 269 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 268 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 269 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 270 | 270 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
| 271 | 271 | $localize['currency_pos'] = wpinv_currency_position(); |
| 272 | 272 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 273 | 273 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 274 | 274 | $localize['decimals'] = wpinv_decimals(); |
| 275 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
| 275 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
| 276 | 276 | $localize['UseTaxes'] = wpinv_use_taxes(); |
| 277 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 277 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
| 278 | 278 | |
| 279 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 279 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
| 280 | 280 | |
| 281 | - wp_enqueue_script( 'jquery-blockui' ); |
|
| 281 | + wp_enqueue_script('jquery-blockui'); |
|
| 282 | 282 | $autofill_api = wpinv_get_option('address_autofill_api'); |
| 283 | 283 | $autofill_active = wpinv_get_option('address_autofill_active'); |
| 284 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
| 285 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
| 286 | - wp_dequeue_script( 'google-maps-api' ); |
|
| 284 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
| 285 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
| 286 | + wp_dequeue_script('google-maps-api'); |
|
| 287 | 287 | } |
| 288 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
| 289 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
| 288 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
| 289 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
| 293 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 292 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
| 293 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 294 | 294 | |
| 295 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
| 296 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 295 | + wp_enqueue_script('wpinv-front-script'); |
|
| 296 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | public function admin_enqueue_scripts() { |
| 300 | 300 | global $post, $pagenow; |
| 301 | 301 | |
| 302 | 302 | $post_type = wpinv_admin_post_type(); |
| 303 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 304 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
| 303 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 304 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
| 305 | 305 | |
| 306 | 306 | $jquery_ui_css = false; |
| 307 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
| 307 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
| 308 | 308 | $jquery_ui_css = true; |
| 309 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
| 309 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
| 310 | 310 | $jquery_ui_css = true; |
| 311 | 311 | } |
| 312 | - if ( $jquery_ui_css ) { |
|
| 313 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
| 314 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
| 312 | + if ($jquery_ui_css) { |
|
| 313 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
| 314 | + wp_enqueue_style('jquery-ui-css'); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
| 318 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
| 317 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
| 318 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
| 319 | 319 | |
| 320 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
| 321 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
| 320 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
| 321 | + wp_enqueue_style('wpinv_admin_style'); |
|
| 322 | 322 | |
| 323 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
| 324 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 325 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 323 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
| 324 | + if ($page == 'wpinv-subscriptions') { |
|
| 325 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
| 329 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 328 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
| 329 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 333 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 332 | + wp_enqueue_style('wp-color-picker'); |
|
| 333 | + wp_enqueue_script('wp-color-picker'); |
|
| 334 | 334 | |
| 335 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 335 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 336 | 336 | |
| 337 | 337 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
| 338 | 338 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -343,20 +343,20 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
| 347 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 346 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
| 347 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 348 | 348 | |
| 349 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
| 350 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
| 349 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
| 350 | + wp_enqueue_script('wpinv-admin-script'); |
|
| 351 | 351 | |
| 352 | 352 | $localize = array(); |
| 353 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 354 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
| 355 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 356 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
| 357 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
| 358 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
| 359 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
| 353 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 354 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
| 355 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 356 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
| 357 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
| 358 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
| 359 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
| 360 | 360 | $localize['tax'] = wpinv_tax_amount(); |
| 361 | 361 | $localize['discount'] = wpinv_discount_amount(); |
| 362 | 362 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -364,69 +364,69 @@ discard block |
||
| 364 | 364 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 365 | 365 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 366 | 366 | $localize['decimals'] = wpinv_decimals(); |
| 367 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
| 368 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
| 369 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
| 370 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
| 371 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
| 372 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
| 373 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
| 374 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
| 375 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
| 376 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
| 377 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
| 378 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
| 379 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
| 380 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
| 381 | - |
|
| 382 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
| 383 | - |
|
| 384 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
| 385 | - |
|
| 386 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 387 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 388 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 367 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
| 368 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
| 369 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
| 370 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
| 371 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
| 372 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
| 373 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
| 374 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
| 375 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
| 376 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
| 377 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
| 378 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
| 379 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
| 380 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
| 381 | + |
|
| 382 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
| 383 | + |
|
| 384 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
| 385 | + |
|
| 386 | + if ($page == 'wpinv-subscriptions') { |
|
| 387 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
| 388 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - public function admin_body_class( $classes ) { |
|
| 392 | + public function admin_body_class($classes) { |
|
| 393 | 393 | global $pagenow, $post, $current_screen; |
| 394 | 394 | |
| 395 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
| 395 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
| 396 | 396 | $classes .= ' wpinv-cpt'; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 399 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 400 | 400 | |
| 401 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
| 402 | - if ( $add_class ) { |
|
| 403 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
| 401 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
| 402 | + if ($add_class) { |
|
| 403 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | $settings_class = array(); |
| 407 | - if ( $page == 'wpinv-settings' ) { |
|
| 408 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
| 409 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
| 407 | + if ($page == 'wpinv-settings') { |
|
| 408 | + if (!empty($_REQUEST['tab'])) { |
|
| 409 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
| 413 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
| 412 | + if (!empty($_REQUEST['section'])) { |
|
| 413 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
| 416 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( !empty( $settings_class ) ) { |
|
| 420 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
| 419 | + if (!empty($settings_class)) { |
|
| 420 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $post_type = wpinv_admin_post_type(); |
| 424 | 424 | |
| 425 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
| 425 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
| 426 | 426 | return $classes .= ' wpinv'; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
| 429 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
| 430 | 430 | $classes .= ' wpi-editable-n'; |
| 431 | 431 | } |
| 432 | 432 | |
@@ -438,21 +438,21 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | public function wpinv_actions() { |
| 441 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 442 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 441 | + if (isset($_REQUEST['wpi_action'])) { |
|
| 442 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - public function pre_get_posts( $wp_query ) { |
|
| 447 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
| 448 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
| 446 | + public function pre_get_posts($wp_query) { |
|
| 447 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
| 448 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | return $wp_query; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | public function bp_invoicing_init() { |
| 455 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 455 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -460,11 +460,11 @@ discard block |
||
| 460 | 460 | * |
| 461 | 461 | */ |
| 462 | 462 | public function register_widgets() { |
| 463 | - register_widget( "WPInv_Checkout_Widget" ); |
|
| 464 | - register_widget( "WPInv_History_Widget" ); |
|
| 465 | - register_widget( "WPInv_Receipt_Widget" ); |
|
| 466 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
| 467 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
| 468 | - register_widget( "WPInv_Messages_Widget" ); |
|
| 463 | + register_widget("WPInv_Checkout_Widget"); |
|
| 464 | + register_widget("WPInv_History_Widget"); |
|
| 465 | + register_widget("WPInv_Receipt_Widget"); |
|
| 466 | + register_widget("WPInv_Subscriptions_Widget"); |
|
| 467 | + register_widget("WPInv_Buy_Item_Widget"); |
|
| 468 | + register_widget("WPInv_Messages_Widget"); |
|
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | \ No newline at end of file |
@@ -6,32 +6,32 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
| 8 | 8 | { |
| 9 | - public static $files = array ( |
|
| 9 | + public static $files = array( |
|
| 10 | 10 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
| 11 | 11 | ); |
| 12 | 12 | |
| 13 | - public static $prefixLengthsPsr4 = array ( |
|
| 13 | + public static $prefixLengthsPsr4 = array( |
|
| 14 | 14 | 'C' => |
| 15 | - array ( |
|
| 15 | + array( |
|
| 16 | 16 | 'Composer\\Installers\\' => 20, |
| 17 | 17 | ), |
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | - public static $prefixDirsPsr4 = array ( |
|
| 20 | + public static $prefixDirsPsr4 = array( |
|
| 21 | 21 | 'Composer\\Installers\\' => |
| 22 | - array ( |
|
| 22 | + array( |
|
| 23 | 23 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
| 24 | 24 | ), |
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | - public static $classMap = array ( |
|
| 27 | + public static $classMap = array( |
|
| 28 | 28 | 'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php', |
| 29 | 29 | 'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php', |
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | 32 | public static function getInitializer(ClassLoader $loader) |
| 33 | 33 | { |
| 34 | - return \Closure::bind(function () use ($loader) { |
|
| 34 | + return \Closure::bind(function() use ($loader) { |
|
| 35 | 35 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
| 36 | 36 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
| 37 | 37 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |
@@ -1,271 +1,271 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | - exit; |
|
| 4 | + exit; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | if ( ! class_exists( "AyeCode_Connect_Helper" ) ) { |
| 8 | - /** |
|
| 9 | - * Allow the quick setup and connection of our AyeCode Connect plugin. |
|
| 10 | - * |
|
| 11 | - * Class AyeCode_Connect_Helper |
|
| 12 | - */ |
|
| 13 | - class AyeCode_Connect_Helper { |
|
| 14 | - |
|
| 15 | - // Hold the version number |
|
| 16 | - var $version = "1.0.1"; |
|
| 17 | - |
|
| 18 | - // Hold the default strings. |
|
| 19 | - var $strings = array(); |
|
| 20 | - |
|
| 21 | - // Hold the default pages. |
|
| 22 | - var $pages = array(); |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * The constructor. |
|
| 26 | - * |
|
| 27 | - * AyeCode_Connect_Helper constructor. |
|
| 28 | - * |
|
| 29 | - * @param array $strings |
|
| 30 | - * @param array $pages |
|
| 31 | - */ |
|
| 32 | - public function __construct( $strings = array(), $pages = array() ) { |
|
| 33 | - |
|
| 34 | - // Only fire if not localhost and the current user has the right permissions. |
|
| 35 | - if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) { |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - // set default strings |
|
| 39 | - $default_strings = array( |
|
| 40 | - 'connect_title' => __( "Thanks for choosing an AyeCode Product!" ), |
|
| 41 | - 'connect_external' => __( "Please confirm you wish to connect your site?" ), |
|
| 42 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ), |
|
| 43 | - 'connect_button' => __( "Connect Site" ), |
|
| 44 | - 'connecting_button' => __( "Connecting..." ), |
|
| 45 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost." ), |
|
| 46 | - 'error' => __( "Something went wrong, please refresh and try again." ), |
|
| 47 | - ); |
|
| 48 | - $this->strings = array_merge( $default_strings, $strings ); |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - // set default pages |
|
| 52 | - $default_pages = array(); |
|
| 53 | - $this->pages = array_merge( $default_pages, $pages ); |
|
| 54 | - |
|
| 55 | - // maybe show connect site notice |
|
| 56 | - add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) ); |
|
| 57 | - |
|
| 58 | - // add ajax action if not already added |
|
| 59 | - if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
| 60 | - add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) ); |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - // add ajax action if not already added |
|
| 65 | - if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
| 66 | - add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Give a way to check we can connect via a external redirect. |
|
| 73 | - */ |
|
| 74 | - public function ayecode_connect_helper_installed(){ |
|
| 75 | - $active = array( |
|
| 76 | - 'gd' => defined('GEODIRECTORY_VERSION') ? true : false, |
|
| 77 | - 'uwp' => defined('USERSWP_VERSION') ? true : false, |
|
| 78 | - 'wpi' => defined('WPINV_VERSION') ? true : false, |
|
| 79 | - ); |
|
| 80 | - wp_send_json_success( $active ); |
|
| 81 | - wp_die(); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Get slug from path |
|
| 86 | - * |
|
| 87 | - * @param string $key |
|
| 88 | - * |
|
| 89 | - * @return string |
|
| 90 | - */ |
|
| 91 | - private function format_plugin_slug( $key ) { |
|
| 92 | - $slug = explode( '/', $key ); |
|
| 93 | - $slug = explode( '.', end( $slug ) ); |
|
| 94 | - |
|
| 95 | - return $slug[0]; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Install and activate the AyeCode Connect Plugin |
|
| 100 | - */ |
|
| 101 | - public function ayecode_connect_install() { |
|
| 102 | - |
|
| 103 | - // bail if localhost |
|
| 104 | - if ( $this->is_localhost() ) { |
|
| 105 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // Explicitly clear the event. |
|
| 109 | - wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() ); |
|
| 110 | - |
|
| 111 | - $success = true; |
|
| 112 | - $plugin_slug = "ayecode-connect"; |
|
| 113 | - if ( ! empty( $plugin_slug ) ) { |
|
| 114 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
| 115 | - require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|
| 116 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
| 117 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
| 118 | - |
|
| 119 | - WP_Filesystem(); |
|
| 120 | - |
|
| 121 | - $skin = new Automatic_Upgrader_Skin; |
|
| 122 | - $upgrader = new WP_Upgrader( $skin ); |
|
| 123 | - $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) ); |
|
| 124 | - $plugin_slug = $plugin_slug; |
|
| 125 | - $plugin = $plugin_slug . '/' . $plugin_slug . '.php'; |
|
| 126 | - $installed = false; |
|
| 127 | - $activate = false; |
|
| 128 | - |
|
| 129 | - // See if the plugin is installed already |
|
| 130 | - if ( in_array( $plugin_slug, $installed_plugins ) ) { |
|
| 131 | - $installed = true; |
|
| 132 | - $activate = ! is_plugin_active( $plugin ); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // Install this thing! |
|
| 136 | - if ( ! $installed ) { |
|
| 137 | - |
|
| 138 | - // Suppress feedback |
|
| 139 | - ob_start(); |
|
| 140 | - |
|
| 141 | - try { |
|
| 142 | - $plugin_information = plugins_api( 'plugin_information', array( |
|
| 143 | - 'slug' => $plugin_slug, |
|
| 144 | - 'fields' => array( |
|
| 145 | - 'short_description' => false, |
|
| 146 | - 'sections' => false, |
|
| 147 | - 'requires' => false, |
|
| 148 | - 'rating' => false, |
|
| 149 | - 'ratings' => false, |
|
| 150 | - 'downloaded' => false, |
|
| 151 | - 'last_updated' => false, |
|
| 152 | - 'added' => false, |
|
| 153 | - 'tags' => false, |
|
| 154 | - 'homepage' => false, |
|
| 155 | - 'donate_link' => false, |
|
| 156 | - 'author_profile' => false, |
|
| 157 | - 'author' => false, |
|
| 158 | - ), |
|
| 159 | - ) ); |
|
| 160 | - |
|
| 161 | - if ( is_wp_error( $plugin_information ) ) { |
|
| 162 | - throw new Exception( $plugin_information->get_error_message() ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $package = $plugin_information->download_link; |
|
| 166 | - $download = $upgrader->download_package( $package ); |
|
| 167 | - |
|
| 168 | - if ( is_wp_error( $download ) ) { |
|
| 169 | - throw new Exception( $download->get_error_message() ); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - $working_dir = $upgrader->unpack_package( $download, true ); |
|
| 173 | - |
|
| 174 | - if ( is_wp_error( $working_dir ) ) { |
|
| 175 | - throw new Exception( $working_dir->get_error_message() ); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - $result = $upgrader->install_package( array( |
|
| 179 | - 'source' => $working_dir, |
|
| 180 | - 'destination' => WP_PLUGIN_DIR, |
|
| 181 | - 'clear_destination' => false, |
|
| 182 | - 'abort_if_destination_exists' => false, |
|
| 183 | - 'clear_working' => true, |
|
| 184 | - 'hook_extra' => array( |
|
| 185 | - 'type' => 'plugin', |
|
| 186 | - 'action' => 'install', |
|
| 187 | - ), |
|
| 188 | - ) ); |
|
| 189 | - |
|
| 190 | - if ( is_wp_error( $result ) ) { |
|
| 191 | - throw new Exception( $result->get_error_message() ); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - $activate = true; |
|
| 195 | - |
|
| 196 | - } catch ( Exception $e ) { |
|
| 197 | - $success = false; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - // Discard feedback |
|
| 201 | - ob_end_clean(); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - wp_clean_plugins_cache(); |
|
| 205 | - |
|
| 206 | - // Activate this thing |
|
| 207 | - if ( $activate ) { |
|
| 208 | - try { |
|
| 209 | - $result = activate_plugin( $plugin ); |
|
| 210 | - |
|
| 211 | - if ( is_wp_error( $result ) ) { |
|
| 212 | - $success = false; |
|
| 213 | - } else { |
|
| 214 | - $success = true; |
|
| 215 | - } |
|
| 216 | - } catch ( Exception $e ) { |
|
| 217 | - $success = false; |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - if ( $success && function_exists( 'ayecode_connect_args' ) ) { |
|
| 223 | - ayecode_connect();// init |
|
| 224 | - $args = ayecode_connect_args(); |
|
| 225 | - $client = new AyeCode_Connect( $args ); |
|
| 226 | - $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : ''; |
|
| 227 | - $redirect = $client->build_connect_url( $redirect_to ); |
|
| 228 | - wp_send_json_success( array( 'connect_url' => $redirect ) ); |
|
| 229 | - } else { |
|
| 230 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
| 231 | - } |
|
| 232 | - wp_die(); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * Check if maybe localhost. |
|
| 237 | - * |
|
| 238 | - * @return bool |
|
| 239 | - */ |
|
| 240 | - public function is_localhost() { |
|
| 241 | - $localhost = false; |
|
| 242 | - |
|
| 243 | - $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : ''; |
|
| 244 | - $localhost_domains = array( |
|
| 245 | - 'localhost', |
|
| 246 | - 'localhost.localdomain', |
|
| 247 | - '127.0.0.1', |
|
| 248 | - '::1' |
|
| 249 | - ); |
|
| 250 | - |
|
| 251 | - if ( in_array( $host, $localhost_domains ) ) { |
|
| 252 | - $localhost = true; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - return $localhost; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Show notice to connect site. |
|
| 260 | - */ |
|
| 261 | - public function ayecode_connect_install_notice() { |
|
| 262 | - if ( $this->maybe_show() ) { |
|
| 263 | - $connect_title_string = $this->strings['connect_title']; |
|
| 264 | - $connect_external_string = $this->strings['connect_external']; |
|
| 265 | - $connect_string = $this->strings['connect']; |
|
| 266 | - $connect_button_string = $this->strings['connect_button']; |
|
| 267 | - $connecting_button_string = $this->strings['connecting_button']; |
|
| 268 | - ?> |
|
| 8 | + /** |
|
| 9 | + * Allow the quick setup and connection of our AyeCode Connect plugin. |
|
| 10 | + * |
|
| 11 | + * Class AyeCode_Connect_Helper |
|
| 12 | + */ |
|
| 13 | + class AyeCode_Connect_Helper { |
|
| 14 | + |
|
| 15 | + // Hold the version number |
|
| 16 | + var $version = "1.0.1"; |
|
| 17 | + |
|
| 18 | + // Hold the default strings. |
|
| 19 | + var $strings = array(); |
|
| 20 | + |
|
| 21 | + // Hold the default pages. |
|
| 22 | + var $pages = array(); |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * The constructor. |
|
| 26 | + * |
|
| 27 | + * AyeCode_Connect_Helper constructor. |
|
| 28 | + * |
|
| 29 | + * @param array $strings |
|
| 30 | + * @param array $pages |
|
| 31 | + */ |
|
| 32 | + public function __construct( $strings = array(), $pages = array() ) { |
|
| 33 | + |
|
| 34 | + // Only fire if not localhost and the current user has the right permissions. |
|
| 35 | + if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) { |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + // set default strings |
|
| 39 | + $default_strings = array( |
|
| 40 | + 'connect_title' => __( "Thanks for choosing an AyeCode Product!" ), |
|
| 41 | + 'connect_external' => __( "Please confirm you wish to connect your site?" ), |
|
| 42 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ), |
|
| 43 | + 'connect_button' => __( "Connect Site" ), |
|
| 44 | + 'connecting_button' => __( "Connecting..." ), |
|
| 45 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost." ), |
|
| 46 | + 'error' => __( "Something went wrong, please refresh and try again." ), |
|
| 47 | + ); |
|
| 48 | + $this->strings = array_merge( $default_strings, $strings ); |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + // set default pages |
|
| 52 | + $default_pages = array(); |
|
| 53 | + $this->pages = array_merge( $default_pages, $pages ); |
|
| 54 | + |
|
| 55 | + // maybe show connect site notice |
|
| 56 | + add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) ); |
|
| 57 | + |
|
| 58 | + // add ajax action if not already added |
|
| 59 | + if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
| 60 | + add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) ); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + // add ajax action if not already added |
|
| 65 | + if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
| 66 | + add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Give a way to check we can connect via a external redirect. |
|
| 73 | + */ |
|
| 74 | + public function ayecode_connect_helper_installed(){ |
|
| 75 | + $active = array( |
|
| 76 | + 'gd' => defined('GEODIRECTORY_VERSION') ? true : false, |
|
| 77 | + 'uwp' => defined('USERSWP_VERSION') ? true : false, |
|
| 78 | + 'wpi' => defined('WPINV_VERSION') ? true : false, |
|
| 79 | + ); |
|
| 80 | + wp_send_json_success( $active ); |
|
| 81 | + wp_die(); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Get slug from path |
|
| 86 | + * |
|
| 87 | + * @param string $key |
|
| 88 | + * |
|
| 89 | + * @return string |
|
| 90 | + */ |
|
| 91 | + private function format_plugin_slug( $key ) { |
|
| 92 | + $slug = explode( '/', $key ); |
|
| 93 | + $slug = explode( '.', end( $slug ) ); |
|
| 94 | + |
|
| 95 | + return $slug[0]; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Install and activate the AyeCode Connect Plugin |
|
| 100 | + */ |
|
| 101 | + public function ayecode_connect_install() { |
|
| 102 | + |
|
| 103 | + // bail if localhost |
|
| 104 | + if ( $this->is_localhost() ) { |
|
| 105 | + wp_send_json_error( $this->strings['error_localhost'] ); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // Explicitly clear the event. |
|
| 109 | + wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() ); |
|
| 110 | + |
|
| 111 | + $success = true; |
|
| 112 | + $plugin_slug = "ayecode-connect"; |
|
| 113 | + if ( ! empty( $plugin_slug ) ) { |
|
| 114 | + require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
| 115 | + require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|
| 116 | + require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
| 117 | + require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
| 118 | + |
|
| 119 | + WP_Filesystem(); |
|
| 120 | + |
|
| 121 | + $skin = new Automatic_Upgrader_Skin; |
|
| 122 | + $upgrader = new WP_Upgrader( $skin ); |
|
| 123 | + $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) ); |
|
| 124 | + $plugin_slug = $plugin_slug; |
|
| 125 | + $plugin = $plugin_slug . '/' . $plugin_slug . '.php'; |
|
| 126 | + $installed = false; |
|
| 127 | + $activate = false; |
|
| 128 | + |
|
| 129 | + // See if the plugin is installed already |
|
| 130 | + if ( in_array( $plugin_slug, $installed_plugins ) ) { |
|
| 131 | + $installed = true; |
|
| 132 | + $activate = ! is_plugin_active( $plugin ); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // Install this thing! |
|
| 136 | + if ( ! $installed ) { |
|
| 137 | + |
|
| 138 | + // Suppress feedback |
|
| 139 | + ob_start(); |
|
| 140 | + |
|
| 141 | + try { |
|
| 142 | + $plugin_information = plugins_api( 'plugin_information', array( |
|
| 143 | + 'slug' => $plugin_slug, |
|
| 144 | + 'fields' => array( |
|
| 145 | + 'short_description' => false, |
|
| 146 | + 'sections' => false, |
|
| 147 | + 'requires' => false, |
|
| 148 | + 'rating' => false, |
|
| 149 | + 'ratings' => false, |
|
| 150 | + 'downloaded' => false, |
|
| 151 | + 'last_updated' => false, |
|
| 152 | + 'added' => false, |
|
| 153 | + 'tags' => false, |
|
| 154 | + 'homepage' => false, |
|
| 155 | + 'donate_link' => false, |
|
| 156 | + 'author_profile' => false, |
|
| 157 | + 'author' => false, |
|
| 158 | + ), |
|
| 159 | + ) ); |
|
| 160 | + |
|
| 161 | + if ( is_wp_error( $plugin_information ) ) { |
|
| 162 | + throw new Exception( $plugin_information->get_error_message() ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $package = $plugin_information->download_link; |
|
| 166 | + $download = $upgrader->download_package( $package ); |
|
| 167 | + |
|
| 168 | + if ( is_wp_error( $download ) ) { |
|
| 169 | + throw new Exception( $download->get_error_message() ); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + $working_dir = $upgrader->unpack_package( $download, true ); |
|
| 173 | + |
|
| 174 | + if ( is_wp_error( $working_dir ) ) { |
|
| 175 | + throw new Exception( $working_dir->get_error_message() ); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + $result = $upgrader->install_package( array( |
|
| 179 | + 'source' => $working_dir, |
|
| 180 | + 'destination' => WP_PLUGIN_DIR, |
|
| 181 | + 'clear_destination' => false, |
|
| 182 | + 'abort_if_destination_exists' => false, |
|
| 183 | + 'clear_working' => true, |
|
| 184 | + 'hook_extra' => array( |
|
| 185 | + 'type' => 'plugin', |
|
| 186 | + 'action' => 'install', |
|
| 187 | + ), |
|
| 188 | + ) ); |
|
| 189 | + |
|
| 190 | + if ( is_wp_error( $result ) ) { |
|
| 191 | + throw new Exception( $result->get_error_message() ); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + $activate = true; |
|
| 195 | + |
|
| 196 | + } catch ( Exception $e ) { |
|
| 197 | + $success = false; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + // Discard feedback |
|
| 201 | + ob_end_clean(); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + wp_clean_plugins_cache(); |
|
| 205 | + |
|
| 206 | + // Activate this thing |
|
| 207 | + if ( $activate ) { |
|
| 208 | + try { |
|
| 209 | + $result = activate_plugin( $plugin ); |
|
| 210 | + |
|
| 211 | + if ( is_wp_error( $result ) ) { |
|
| 212 | + $success = false; |
|
| 213 | + } else { |
|
| 214 | + $success = true; |
|
| 215 | + } |
|
| 216 | + } catch ( Exception $e ) { |
|
| 217 | + $success = false; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + if ( $success && function_exists( 'ayecode_connect_args' ) ) { |
|
| 223 | + ayecode_connect();// init |
|
| 224 | + $args = ayecode_connect_args(); |
|
| 225 | + $client = new AyeCode_Connect( $args ); |
|
| 226 | + $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : ''; |
|
| 227 | + $redirect = $client->build_connect_url( $redirect_to ); |
|
| 228 | + wp_send_json_success( array( 'connect_url' => $redirect ) ); |
|
| 229 | + } else { |
|
| 230 | + wp_send_json_error( $this->strings['error_localhost'] ); |
|
| 231 | + } |
|
| 232 | + wp_die(); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * Check if maybe localhost. |
|
| 237 | + * |
|
| 238 | + * @return bool |
|
| 239 | + */ |
|
| 240 | + public function is_localhost() { |
|
| 241 | + $localhost = false; |
|
| 242 | + |
|
| 243 | + $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : ''; |
|
| 244 | + $localhost_domains = array( |
|
| 245 | + 'localhost', |
|
| 246 | + 'localhost.localdomain', |
|
| 247 | + '127.0.0.1', |
|
| 248 | + '::1' |
|
| 249 | + ); |
|
| 250 | + |
|
| 251 | + if ( in_array( $host, $localhost_domains ) ) { |
|
| 252 | + $localhost = true; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + return $localhost; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Show notice to connect site. |
|
| 260 | + */ |
|
| 261 | + public function ayecode_connect_install_notice() { |
|
| 262 | + if ( $this->maybe_show() ) { |
|
| 263 | + $connect_title_string = $this->strings['connect_title']; |
|
| 264 | + $connect_external_string = $this->strings['connect_external']; |
|
| 265 | + $connect_string = $this->strings['connect']; |
|
| 266 | + $connect_button_string = $this->strings['connect_button']; |
|
| 267 | + $connecting_button_string = $this->strings['connecting_button']; |
|
| 268 | + ?> |
|
| 269 | 269 | <div class="notice notice-info acch-notice"> |
| 270 | 270 | <span class="acch-float-left"> |
| 271 | 271 | <svg width="61px" height="61px" viewBox="0 0 61 61" version="1.1" |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | <h3 class="acch-title"><?php echo esc_attr( $connect_title_string ); ?></h3> |
| 305 | 305 | <p> |
| 306 | 306 | <?php |
| 307 | - echo $connect_string; |
|
| 308 | - ?> |
|
| 307 | + echo $connect_string; |
|
| 308 | + ?> |
|
| 309 | 309 | </p> |
| 310 | 310 | </span> |
| 311 | 311 | |
@@ -318,9 +318,9 @@ discard block |
||
| 318 | 318 | </div> |
| 319 | 319 | |
| 320 | 320 | <?php |
| 321 | - // only include the popup HTML if needed. |
|
| 322 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
| 323 | - ?> |
|
| 321 | + // only include the popup HTML if needed. |
|
| 322 | + if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
| 323 | + ?> |
|
| 324 | 324 | <div id="ayecode-connect-helper-external-confirm" style="display:none;"> |
| 325 | 325 | <div class="noticex notice-info acch-notice" style="border: none;"> |
| 326 | 326 | <span class="acch-float-left"> |
@@ -369,23 +369,23 @@ discard block |
||
| 369 | 369 | </div> |
| 370 | 370 | </div> |
| 371 | 371 | <?php |
| 372 | - } |
|
| 373 | - |
|
| 374 | - // add required scripts |
|
| 375 | - $this->script(); |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * Get the JS Script. |
|
| 381 | - */ |
|
| 382 | - public function script() { |
|
| 383 | - |
|
| 384 | - // add thickbox if external request is requested |
|
| 385 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
| 386 | - add_thickbox(); |
|
| 387 | - } |
|
| 388 | - ?> |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + // add required scripts |
|
| 375 | + $this->script(); |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * Get the JS Script. |
|
| 381 | + */ |
|
| 382 | + public function script() { |
|
| 383 | + |
|
| 384 | + // add thickbox if external request is requested |
|
| 385 | + if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
| 386 | + add_thickbox(); |
|
| 387 | + } |
|
| 388 | + ?> |
|
| 389 | 389 | <style> |
| 390 | 390 | .acch-title { |
| 391 | 391 | margin: 0; |
@@ -454,43 +454,43 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | |
| 456 | 456 | <?php |
| 457 | - // add thickbox if external request is requested |
|
| 458 | - if(! empty( $_REQUEST['external-connect-request'] )) { |
|
| 459 | - ?> |
|
| 457 | + // add thickbox if external request is requested |
|
| 458 | + if(! empty( $_REQUEST['external-connect-request'] )) { |
|
| 459 | + ?> |
|
| 460 | 460 | jQuery(function () { |
| 461 | 461 | setTimeout(function () { |
| 462 | 462 | tb_show("AyeCode Connect", "?TB_inline?width=300&height=80&inlineId=ayecode-connect-helper-external-confirm"); |
| 463 | 463 | }, 200); |
| 464 | 464 | }); |
| 465 | 465 | <?php |
| 466 | - } |
|
| 467 | - ?> |
|
| 466 | + } |
|
| 467 | + ?> |
|
| 468 | 468 | |
| 469 | 469 | </script> |
| 470 | 470 | <?php |
| 471 | - } |
|
| 472 | - |
|
| 473 | - /** |
|
| 474 | - * Decide what pages to show on. |
|
| 475 | - * |
|
| 476 | - * @return bool |
|
| 477 | - */ |
|
| 478 | - public function maybe_show() { |
|
| 479 | - $show = false; |
|
| 480 | - |
|
| 481 | - // check if on a page set to show |
|
| 482 | - if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) { |
|
| 483 | - |
|
| 484 | - // check if not active and connected |
|
| 485 | - if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) { |
|
| 486 | - $show = true; |
|
| 487 | - } |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + /** |
|
| 474 | + * Decide what pages to show on. |
|
| 475 | + * |
|
| 476 | + * @return bool |
|
| 477 | + */ |
|
| 478 | + public function maybe_show() { |
|
| 479 | + $show = false; |
|
| 480 | + |
|
| 481 | + // check if on a page set to show |
|
| 482 | + if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) { |
|
| 483 | + |
|
| 484 | + // check if not active and connected |
|
| 485 | + if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) { |
|
| 486 | + $show = true; |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - } |
|
| 489 | + } |
|
| 490 | 490 | |
| 491 | - return $show; |
|
| 492 | - } |
|
| 491 | + return $show; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | - } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | } |
@@ -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_Connect_Helper" ) ) { |
|
| 7 | +if (!class_exists("AyeCode_Connect_Helper")) { |
|
| 8 | 8 | /** |
| 9 | 9 | * Allow the quick setup and connection of our AyeCode Connect plugin. |
| 10 | 10 | * |
@@ -29,41 +29,41 @@ discard block |
||
| 29 | 29 | * @param array $strings |
| 30 | 30 | * @param array $pages |
| 31 | 31 | */ |
| 32 | - public function __construct( $strings = array(), $pages = array() ) { |
|
| 32 | + public function __construct($strings = array(), $pages = array()) { |
|
| 33 | 33 | |
| 34 | 34 | // Only fire if not localhost and the current user has the right permissions. |
| 35 | - if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) { |
|
| 35 | + if (!$this->is_localhost() && current_user_can('manage_options')) { |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | // set default strings |
| 39 | 39 | $default_strings = array( |
| 40 | - 'connect_title' => __( "Thanks for choosing an AyeCode Product!" ), |
|
| 41 | - 'connect_external' => __( "Please confirm you wish to connect your site?" ), |
|
| 42 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ), |
|
| 43 | - 'connect_button' => __( "Connect Site" ), |
|
| 44 | - 'connecting_button' => __( "Connecting..." ), |
|
| 45 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost." ), |
|
| 46 | - 'error' => __( "Something went wrong, please refresh and try again." ), |
|
| 40 | + 'connect_title' => __("Thanks for choosing an AyeCode Product!"), |
|
| 41 | + 'connect_external' => __("Please confirm you wish to connect your site?"), |
|
| 42 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
| 43 | + 'connect_button' => __("Connect Site"), |
|
| 44 | + 'connecting_button' => __("Connecting..."), |
|
| 45 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost."), |
|
| 46 | + 'error' => __("Something went wrong, please refresh and try again."), |
|
| 47 | 47 | ); |
| 48 | - $this->strings = array_merge( $default_strings, $strings ); |
|
| 48 | + $this->strings = array_merge($default_strings, $strings); |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | // set default pages |
| 52 | 52 | $default_pages = array(); |
| 53 | - $this->pages = array_merge( $default_pages, $pages ); |
|
| 53 | + $this->pages = array_merge($default_pages, $pages); |
|
| 54 | 54 | |
| 55 | 55 | // maybe show connect site notice |
| 56 | - add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) ); |
|
| 56 | + add_action('admin_notices', array($this, 'ayecode_connect_install_notice')); |
|
| 57 | 57 | |
| 58 | 58 | // add ajax action if not already added |
| 59 | - if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
| 60 | - add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) ); |
|
| 59 | + if (!has_action('wp_ajax_ayecode_connect_helper')) { |
|
| 60 | + add_action('wp_ajax_ayecode_connect_helper', array($this, 'ayecode_connect_install')); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // add ajax action if not already added |
| 65 | - if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) { |
|
| 66 | - add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) ); |
|
| 65 | + if (!has_action('wp_ajax_ayecode_connect_helper')) { |
|
| 66 | + add_action('wp_ajax_nopriv_ayecode_connect_helper_installed', array($this, 'ayecode_connect_helper_installed')); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | } |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | /** |
| 72 | 72 | * Give a way to check we can connect via a external redirect. |
| 73 | 73 | */ |
| 74 | - public function ayecode_connect_helper_installed(){ |
|
| 74 | + public function ayecode_connect_helper_installed() { |
|
| 75 | 75 | $active = array( |
| 76 | 76 | 'gd' => defined('GEODIRECTORY_VERSION') ? true : false, |
| 77 | 77 | 'uwp' => defined('USERSWP_VERSION') ? true : false, |
| 78 | 78 | 'wpi' => defined('WPINV_VERSION') ? true : false, |
| 79 | 79 | ); |
| 80 | - wp_send_json_success( $active ); |
|
| 80 | + wp_send_json_success($active); |
|
| 81 | 81 | wp_die(); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string |
| 90 | 90 | */ |
| 91 | - private function format_plugin_slug( $key ) { |
|
| 92 | - $slug = explode( '/', $key ); |
|
| 93 | - $slug = explode( '.', end( $slug ) ); |
|
| 91 | + private function format_plugin_slug($key) { |
|
| 92 | + $slug = explode('/', $key); |
|
| 93 | + $slug = explode('.', end($slug)); |
|
| 94 | 94 | |
| 95 | 95 | return $slug[0]; |
| 96 | 96 | } |
@@ -101,45 +101,45 @@ discard block |
||
| 101 | 101 | public function ayecode_connect_install() { |
| 102 | 102 | |
| 103 | 103 | // bail if localhost |
| 104 | - if ( $this->is_localhost() ) { |
|
| 105 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
| 104 | + if ($this->is_localhost()) { |
|
| 105 | + wp_send_json_error($this->strings['error_localhost']); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Explicitly clear the event. |
| 109 | - wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() ); |
|
| 109 | + wp_clear_scheduled_hook('geodir_plugin_background_installer', func_get_args()); |
|
| 110 | 110 | |
| 111 | 111 | $success = true; |
| 112 | 112 | $plugin_slug = "ayecode-connect"; |
| 113 | - if ( ! empty( $plugin_slug ) ) { |
|
| 114 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
| 115 | - require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|
| 116 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
| 117 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
| 113 | + if (!empty($plugin_slug)) { |
|
| 114 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 115 | + require_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); |
|
| 116 | + require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'); |
|
| 117 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 118 | 118 | |
| 119 | 119 | WP_Filesystem(); |
| 120 | 120 | |
| 121 | 121 | $skin = new Automatic_Upgrader_Skin; |
| 122 | - $upgrader = new WP_Upgrader( $skin ); |
|
| 123 | - $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) ); |
|
| 122 | + $upgrader = new WP_Upgrader($skin); |
|
| 123 | + $installed_plugins = array_map(array($this, 'format_plugin_slug'), array_keys(get_plugins())); |
|
| 124 | 124 | $plugin_slug = $plugin_slug; |
| 125 | 125 | $plugin = $plugin_slug . '/' . $plugin_slug . '.php'; |
| 126 | 126 | $installed = false; |
| 127 | 127 | $activate = false; |
| 128 | 128 | |
| 129 | 129 | // See if the plugin is installed already |
| 130 | - if ( in_array( $plugin_slug, $installed_plugins ) ) { |
|
| 130 | + if (in_array($plugin_slug, $installed_plugins)) { |
|
| 131 | 131 | $installed = true; |
| 132 | - $activate = ! is_plugin_active( $plugin ); |
|
| 132 | + $activate = !is_plugin_active($plugin); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Install this thing! |
| 136 | - if ( ! $installed ) { |
|
| 136 | + if (!$installed) { |
|
| 137 | 137 | |
| 138 | 138 | // Suppress feedback |
| 139 | 139 | ob_start(); |
| 140 | 140 | |
| 141 | 141 | try { |
| 142 | - $plugin_information = plugins_api( 'plugin_information', array( |
|
| 142 | + $plugin_information = plugins_api('plugin_information', array( |
|
| 143 | 143 | 'slug' => $plugin_slug, |
| 144 | 144 | 'fields' => array( |
| 145 | 145 | 'short_description' => false, |
@@ -156,26 +156,26 @@ discard block |
||
| 156 | 156 | 'author_profile' => false, |
| 157 | 157 | 'author' => false, |
| 158 | 158 | ), |
| 159 | - ) ); |
|
| 159 | + )); |
|
| 160 | 160 | |
| 161 | - if ( is_wp_error( $plugin_information ) ) { |
|
| 162 | - throw new Exception( $plugin_information->get_error_message() ); |
|
| 161 | + if (is_wp_error($plugin_information)) { |
|
| 162 | + throw new Exception($plugin_information->get_error_message()); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $package = $plugin_information->download_link; |
| 166 | - $download = $upgrader->download_package( $package ); |
|
| 166 | + $download = $upgrader->download_package($package); |
|
| 167 | 167 | |
| 168 | - if ( is_wp_error( $download ) ) { |
|
| 169 | - throw new Exception( $download->get_error_message() ); |
|
| 168 | + if (is_wp_error($download)) { |
|
| 169 | + throw new Exception($download->get_error_message()); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $working_dir = $upgrader->unpack_package( $download, true ); |
|
| 172 | + $working_dir = $upgrader->unpack_package($download, true); |
|
| 173 | 173 | |
| 174 | - if ( is_wp_error( $working_dir ) ) { |
|
| 175 | - throw new Exception( $working_dir->get_error_message() ); |
|
| 174 | + if (is_wp_error($working_dir)) { |
|
| 175 | + throw new Exception($working_dir->get_error_message()); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - $result = $upgrader->install_package( array( |
|
| 178 | + $result = $upgrader->install_package(array( |
|
| 179 | 179 | 'source' => $working_dir, |
| 180 | 180 | 'destination' => WP_PLUGIN_DIR, |
| 181 | 181 | 'clear_destination' => false, |
@@ -185,15 +185,15 @@ discard block |
||
| 185 | 185 | 'type' => 'plugin', |
| 186 | 186 | 'action' => 'install', |
| 187 | 187 | ), |
| 188 | - ) ); |
|
| 188 | + )); |
|
| 189 | 189 | |
| 190 | - if ( is_wp_error( $result ) ) { |
|
| 191 | - throw new Exception( $result->get_error_message() ); |
|
| 190 | + if (is_wp_error($result)) { |
|
| 191 | + throw new Exception($result->get_error_message()); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | $activate = true; |
| 195 | 195 | |
| 196 | - } catch ( Exception $e ) { |
|
| 196 | + } catch (Exception $e) { |
|
| 197 | 197 | $success = false; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -204,30 +204,30 @@ discard block |
||
| 204 | 204 | wp_clean_plugins_cache(); |
| 205 | 205 | |
| 206 | 206 | // Activate this thing |
| 207 | - if ( $activate ) { |
|
| 207 | + if ($activate) { |
|
| 208 | 208 | try { |
| 209 | - $result = activate_plugin( $plugin ); |
|
| 209 | + $result = activate_plugin($plugin); |
|
| 210 | 210 | |
| 211 | - if ( is_wp_error( $result ) ) { |
|
| 211 | + if (is_wp_error($result)) { |
|
| 212 | 212 | $success = false; |
| 213 | 213 | } else { |
| 214 | 214 | $success = true; |
| 215 | 215 | } |
| 216 | - } catch ( Exception $e ) { |
|
| 216 | + } catch (Exception $e) { |
|
| 217 | 217 | $success = false; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if ( $success && function_exists( 'ayecode_connect_args' ) ) { |
|
| 223 | - ayecode_connect();// init |
|
| 222 | + if ($success && function_exists('ayecode_connect_args')) { |
|
| 223 | + ayecode_connect(); // init |
|
| 224 | 224 | $args = ayecode_connect_args(); |
| 225 | - $client = new AyeCode_Connect( $args ); |
|
| 226 | - $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : ''; |
|
| 227 | - $redirect = $client->build_connect_url( $redirect_to ); |
|
| 228 | - wp_send_json_success( array( 'connect_url' => $redirect ) ); |
|
| 225 | + $client = new AyeCode_Connect($args); |
|
| 226 | + $redirect_to = !empty($_POST['redirect_to']) ? esc_url_raw($_POST['redirect_to']) : ''; |
|
| 227 | + $redirect = $client->build_connect_url($redirect_to); |
|
| 228 | + wp_send_json_success(array('connect_url' => $redirect)); |
|
| 229 | 229 | } else { |
| 230 | - wp_send_json_error( $this->strings['error_localhost'] ); |
|
| 230 | + wp_send_json_error($this->strings['error_localhost']); |
|
| 231 | 231 | } |
| 232 | 232 | wp_die(); |
| 233 | 233 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | public function is_localhost() { |
| 241 | 241 | $localhost = false; |
| 242 | 242 | |
| 243 | - $host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : ''; |
|
| 243 | + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; |
|
| 244 | 244 | $localhost_domains = array( |
| 245 | 245 | 'localhost', |
| 246 | 246 | 'localhost.localdomain', |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | '::1' |
| 249 | 249 | ); |
| 250 | 250 | |
| 251 | - if ( in_array( $host, $localhost_domains ) ) { |
|
| 251 | + if (in_array($host, $localhost_domains)) { |
|
| 252 | 252 | $localhost = true; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * Show notice to connect site. |
| 260 | 260 | */ |
| 261 | 261 | public function ayecode_connect_install_notice() { |
| 262 | - if ( $this->maybe_show() ) { |
|
| 262 | + if ($this->maybe_show()) { |
|
| 263 | 263 | $connect_title_string = $this->strings['connect_title']; |
| 264 | 264 | $connect_external_string = $this->strings['connect_external']; |
| 265 | 265 | $connect_string = $this->strings['connect']; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | </svg> |
| 302 | 302 | </span> |
| 303 | 303 | <span class="acch-float-left acch-text"> |
| 304 | - <h3 class="acch-title"><?php echo esc_attr( $connect_title_string ); ?></h3> |
|
| 304 | + <h3 class="acch-title"><?php echo esc_attr($connect_title_string); ?></h3> |
|
| 305 | 305 | <p> |
| 306 | 306 | <?php |
| 307 | 307 | echo $connect_string; |
@@ -312,14 +312,14 @@ discard block |
||
| 312 | 312 | <span class="acch-float-left acch-button"> |
| 313 | 313 | <button onclick="ayecode_connect_helper(this);" id="gd-connect-site" |
| 314 | 314 | class="button button-primary" |
| 315 | - data-connecting="<?php echo esc_attr( $connecting_button_string ); ?>"><?php echo esc_attr( $connect_button_string ) ?></button> |
|
| 315 | + data-connecting="<?php echo esc_attr($connecting_button_string); ?>"><?php echo esc_attr($connect_button_string) ?></button> |
|
| 316 | 316 | </span> |
| 317 | 317 | |
| 318 | 318 | </div> |
| 319 | 319 | |
| 320 | 320 | <?php |
| 321 | 321 | // only include the popup HTML if needed. |
| 322 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
| 322 | + if (!empty($_REQUEST['external-connect-request'])) { |
|
| 323 | 323 | ?> |
| 324 | 324 | <div id="ayecode-connect-helper-external-confirm" style="display:none;"> |
| 325 | 325 | <div class="noticex notice-info acch-notice" style="border: none;"> |
@@ -357,13 +357,13 @@ discard block |
||
| 357 | 357 | </svg> |
| 358 | 358 | </span> |
| 359 | 359 | <span class="acch-float-left acch-text"> |
| 360 | - <h3 class="acch-title"><?php echo esc_attr( $connect_external_string ); ?></h3> |
|
| 360 | + <h3 class="acch-title"><?php echo esc_attr($connect_external_string); ?></h3> |
|
| 361 | 361 | </span> |
| 362 | 362 | |
| 363 | 363 | <span class="acch-float-left acch-button"> |
| 364 | 364 | <button onclick="ayecode_connect_helper(this);" id="gd-connect-site" |
| 365 | 365 | class="button button-primary" |
| 366 | - data-connecting="<?php echo esc_attr( $connecting_button_string ); ?>"><?php echo esc_attr( $connect_button_string ) ?></button> |
|
| 366 | + data-connecting="<?php echo esc_attr($connecting_button_string); ?>"><?php echo esc_attr($connect_button_string) ?></button> |
|
| 367 | 367 | </span> |
| 368 | 368 | |
| 369 | 369 | </div> |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | public function script() { |
| 383 | 383 | |
| 384 | 384 | // add thickbox if external request is requested |
| 385 | - if ( ! empty( $_REQUEST['external-connect-request'] ) ) { |
|
| 385 | + if (!empty($_REQUEST['external-connect-request'])) { |
|
| 386 | 386 | add_thickbox(); |
| 387 | 387 | } |
| 388 | 388 | ?> |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | url: ajaxurl, |
| 435 | 435 | data: { |
| 436 | 436 | action: 'ayecode_connect_helper', |
| 437 | - security: '<?php echo wp_create_nonce( 'ayecode-connect-helper' );?>', |
|
| 437 | + security: '<?php echo wp_create_nonce('ayecode-connect-helper'); ?>', |
|
| 438 | 438 | redirect_to: $current_url |
| 439 | 439 | }, |
| 440 | 440 | beforeSend: function () { |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | |
| 456 | 456 | <?php |
| 457 | 457 | // add thickbox if external request is requested |
| 458 | - if(! empty( $_REQUEST['external-connect-request'] )) { |
|
| 458 | + if (!empty($_REQUEST['external-connect-request'])) { |
|
| 459 | 459 | ?> |
| 460 | 460 | jQuery(function () { |
| 461 | 461 | setTimeout(function () { |
@@ -479,10 +479,10 @@ discard block |
||
| 479 | 479 | $show = false; |
| 480 | 480 | |
| 481 | 481 | // check if on a page set to show |
| 482 | - if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) { |
|
| 482 | + if (isset($_REQUEST['page']) && in_array($_REQUEST['page'], $this->pages)) { |
|
| 483 | 483 | |
| 484 | 484 | // check if not active and connected |
| 485 | - if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) { |
|
| 485 | + if (!defined('AYECODE_CONNECT_VERSION') || !get_option('ayecode_connect_blog_token')) { |
|
| 486 | 486 | $show = true; |
| 487 | 487 | } |
| 488 | 488 | |