| Total Complexity | 68 |
| Total Lines | 520 |
| Duplicated Lines | 0 % |
| Changes | 18 | ||
| Bugs | 2 | Features | 2 |
Complex classes like WPInv_Plugin often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use WPInv_Plugin, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 15 | class WPInv_Plugin { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * GetPaid version. |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | public $version; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Data container. |
||
| 26 | * |
||
| 27 | * @var array |
||
| 28 | */ |
||
| 29 | protected $data = array(); |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Form elements instance. |
||
| 33 | * |
||
| 34 | * @var WPInv_Payment_Form_Elements |
||
| 35 | */ |
||
| 36 | public $form_elements; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Tax instance. |
||
| 40 | * |
||
| 41 | * @var WPInv_EUVat |
||
| 42 | */ |
||
| 43 | public $tax; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param array An array of payment gateways. |
||
| 47 | */ |
||
| 48 | public $gateways; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Class constructor. |
||
| 52 | */ |
||
| 53 | public function __construct() { |
||
| 54 | $this->define_constants(); |
||
| 55 | $this->includes(); |
||
| 56 | $this->init_hooks(); |
||
| 57 | $this->set_properties(); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Sets a custom data property. |
||
| 62 | * |
||
| 63 | * @param string $prop The prop to set. |
||
| 64 | * @param mixed $value The value to retrieve. |
||
| 65 | */ |
||
| 66 | public function set( $prop, $value ) { |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Gets a custom data property. |
||
| 72 | * |
||
| 73 | * @param string $prop The prop to set. |
||
| 74 | * @return mixed The value. |
||
| 75 | */ |
||
| 76 | public function get( $prop ) { |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Define class properties. |
||
| 87 | */ |
||
| 88 | public function set_properties() { |
||
| 89 | |||
| 90 | // Sessions. |
||
| 91 | $this->set( 'session', new WPInv_Session_Handler() ); |
||
| 92 | $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
||
| 93 | $this->form_elements = new WPInv_Payment_Form_Elements(); |
||
| 94 | $this->tax = new WPInv_EUVat(); |
||
| 95 | $this->tax->init(); |
||
| 96 | $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
||
| 97 | |||
| 98 | // Init other objects. |
||
| 99 | $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
||
| 100 | $this->set( 'session', new WPInv_Session_Handler() ); |
||
| 101 | $this->set( 'notes', new WPInv_Notes() ); |
||
| 102 | $this->set( 'api', new WPInv_API() ); |
||
| 103 | $this->set( 'post_types', new GetPaid_Post_Types() ); |
||
| 104 | $this->set( 'template', new GetPaid_Template() ); |
||
| 105 | $this->set( 'admin', new GetPaid_Admin() ); |
||
| 106 | $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
||
| 107 | $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
||
| 108 | |||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Define plugin constants. |
||
| 113 | */ |
||
| 114 | public function define_constants() { |
||
| 115 | define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
||
| 116 | define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
||
| 117 | $this->version = WPINV_VERSION; |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Hook into actions and filters. |
||
| 122 | * |
||
| 123 | * @since 1.0.19 |
||
| 124 | */ |
||
| 125 | protected function init_hooks() { |
||
| 126 | /* Internationalize the text strings used. */ |
||
| 127 | add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
||
| 128 | |||
| 129 | // Init the plugin after WordPress inits. |
||
| 130 | add_action( 'init', array( $this, 'init' ), 1 ); |
||
| 131 | add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 ); |
||
| 132 | add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
||
| 133 | add_action( 'init', array( $this, 'maybe_do_authenticated_action' ) ); |
||
| 134 | |||
| 135 | if ( class_exists( 'BuddyPress' ) ) { |
||
| 136 | add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
||
| 137 | } |
||
| 138 | |||
| 139 | add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
||
| 140 | add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
||
| 141 | add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
||
| 142 | add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
||
| 143 | add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
||
| 144 | |||
| 145 | // Fires after registering actions. |
||
| 146 | do_action( 'wpinv_actions', $this ); |
||
| 147 | do_action( 'getpaid_actions', $this ); |
||
| 148 | |||
| 149 | } |
||
| 150 | |||
| 151 | public function plugins_loaded() { |
||
| 152 | /* Internationalize the text strings used. */ |
||
| 153 | $this->load_textdomain(); |
||
| 154 | |||
| 155 | do_action( 'wpinv_loaded' ); |
||
| 156 | |||
| 157 | // Fix oxygen page builder conflict |
||
| 158 | if ( function_exists( 'ct_css_output' ) ) { |
||
| 159 | wpinv_oxygen_fix_conflict(); |
||
| 160 | } |
||
| 161 | } |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Load the translation of the plugin. |
||
| 165 | * |
||
| 166 | * @since 1.0 |
||
| 167 | */ |
||
| 168 | public function load_textdomain( $locale = NULL ) { |
||
| 169 | if ( empty( $locale ) ) { |
||
| 170 | $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
||
| 171 | } |
||
| 172 | |||
| 173 | $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
||
|
|
|||
| 174 | |||
| 175 | unload_textdomain( 'invoicing' ); |
||
| 176 | load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
||
| 177 | load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Define language constants. |
||
| 181 | */ |
||
| 182 | require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
||
| 183 | } |
||
| 184 | |||
| 185 | /** |
||
| 186 | * Include required core files used in admin and on the frontend. |
||
| 187 | */ |
||
| 188 | public function includes() { |
||
| 189 | |||
| 190 | // Start with the settings. |
||
| 191 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
||
| 192 | |||
| 193 | // Packages/libraries. |
||
| 194 | require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
||
| 195 | require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
||
| 196 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' ); |
||
| 197 | |||
| 198 | // Load functions. |
||
| 199 | require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
||
| 200 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
||
| 201 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
||
| 202 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
||
| 203 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
||
| 204 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
||
| 205 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
||
| 206 | require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
||
| 207 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
||
| 208 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
||
| 209 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
||
| 210 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
||
| 211 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
||
| 212 | require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
||
| 213 | |||
| 214 | // Register autoloader. |
||
| 215 | try { |
||
| 216 | spl_autoload_register( array( $this, 'autoload' ), true ); |
||
| 217 | } catch ( Exception $e ) { |
||
| 218 | wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
||
| 219 | } |
||
| 220 | |||
| 221 | require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
||
| 222 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
||
| 223 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
||
| 224 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
||
| 225 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
||
| 226 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
||
| 227 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
||
| 228 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
||
| 229 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
||
| 230 | require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
||
| 231 | require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
||
| 232 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
||
| 233 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
||
| 234 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
||
| 235 | require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
||
| 236 | require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
||
| 237 | require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
||
| 238 | require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
||
| 239 | require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
||
| 240 | require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
||
| 241 | require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
||
| 242 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
||
| 243 | |||
| 244 | /** |
||
| 245 | * Load the tax class. |
||
| 246 | */ |
||
| 247 | if ( ! class_exists( 'WPInv_EUVat' ) ) { |
||
| 248 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
||
| 249 | } |
||
| 250 | |||
| 251 | $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
||
| 252 | if ( !empty( $gateways ) ) { |
||
| 253 | foreach ( $gateways as $gateway ) { |
||
| 254 | if ( $gateway == 'manual' ) { |
||
| 255 | continue; |
||
| 256 | } |
||
| 257 | |||
| 258 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
||
| 259 | |||
| 260 | if ( file_exists( $gateway_file ) ) { |
||
| 261 | require_once( $gateway_file ); |
||
| 262 | } |
||
| 263 | } |
||
| 264 | } |
||
| 265 | |||
| 266 | if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
||
| 267 | GetPaid_Post_Types_Admin::init(); |
||
| 268 | |||
| 269 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
||
| 270 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
||
| 271 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
||
| 272 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
||
| 273 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
||
| 274 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
||
| 275 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
||
| 276 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
||
| 277 | // load the user class only on the users.php page |
||
| 278 | global $pagenow; |
||
| 279 | if($pagenow=='users.php'){ |
||
| 280 | new WPInv_Admin_Users(); |
||
| 281 | } |
||
| 282 | } |
||
| 283 | |||
| 284 | // Register cli commands |
||
| 285 | if ( defined( 'WP_CLI' ) && WP_CLI ) { |
||
| 286 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
||
| 287 | WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
||
| 288 | } |
||
| 289 | |||
| 290 | // include css inliner |
||
| 291 | if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
||
| 292 | include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
||
| 293 | } |
||
| 294 | |||
| 295 | require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
||
| 296 | } |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Class autoloader |
||
| 300 | * |
||
| 301 | * @param string $class_name The name of the class to load. |
||
| 302 | * @access public |
||
| 303 | * @since 1.0.19 |
||
| 304 | * @return void |
||
| 305 | */ |
||
| 306 | public function autoload( $class_name ) { |
||
| 307 | |||
| 308 | // Normalize the class name... |
||
| 309 | $class_name = strtolower( $class_name ); |
||
| 310 | |||
| 311 | // ... and make sure it is our class. |
||
| 312 | if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
||
| 313 | return; |
||
| 314 | } |
||
| 315 | |||
| 316 | // Next, prepare the file name from the class. |
||
| 317 | $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
||
| 318 | |||
| 319 | // Base path of the classes. |
||
| 320 | $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
||
| 321 | |||
| 322 | // And an array of possible locations in order of importance. |
||
| 323 | $locations = array( |
||
| 324 | "$plugin_path/includes", |
||
| 325 | "$plugin_path/includes/data-stores", |
||
| 326 | "$plugin_path/includes/gateways", |
||
| 327 | "$plugin_path/includes/api", |
||
| 328 | "$plugin_path/includes/admin", |
||
| 329 | "$plugin_path/includes/admin/meta-boxes", |
||
| 330 | ); |
||
| 331 | |||
| 332 | foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
||
| 333 | |||
| 334 | if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
||
| 335 | include trailingslashit( $location ) . $file_name; |
||
| 336 | break; |
||
| 337 | } |
||
| 338 | |||
| 339 | } |
||
| 340 | |||
| 341 | } |
||
| 342 | |||
| 343 | /** |
||
| 344 | * Inits hooks etc. |
||
| 345 | */ |
||
| 346 | public function init() { |
||
| 347 | |||
| 348 | // Fires before getpaid inits. |
||
| 349 | do_action( 'before_getpaid_init', $this ); |
||
| 350 | |||
| 351 | // Load default gateways. |
||
| 352 | $gateways = apply_filters( |
||
| 353 | 'getpaid_default_gateways', |
||
| 354 | array( |
||
| 355 | 'manual' => 'GetPaid_Manual_Gateway', |
||
| 356 | 'paypal' => 'GetPaid_Paypal_Gateway', |
||
| 357 | 'worldpay' => 'GetPaid_Worldpay_Gateway', |
||
| 358 | 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
||
| 359 | 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
||
| 360 | ) |
||
| 361 | ); |
||
| 362 | |||
| 363 | foreach ( $gateways as $id => $class ) { |
||
| 364 | $this->gateways[ $id ] = new $class(); |
||
| 365 | } |
||
| 366 | |||
| 367 | // Fires after getpaid inits. |
||
| 368 | do_action( 'getpaid_init', $this ); |
||
| 369 | |||
| 370 | } |
||
| 371 | |||
| 372 | /** |
||
| 373 | * Checks if this is an IPN request and processes it. |
||
| 374 | */ |
||
| 375 | public function maybe_process_ipn() { |
||
| 376 | |||
| 377 | // Ensure that this is an IPN request. |
||
| 378 | if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
||
| 379 | return; |
||
| 380 | } |
||
| 381 | |||
| 382 | $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
||
| 383 | |||
| 384 | do_action( 'wpinv_verify_payment_ipn', $gateway ); |
||
| 385 | do_action( "wpinv_verify_{$gateway}_ipn" ); |
||
| 386 | exit; |
||
| 387 | |||
| 388 | } |
||
| 389 | |||
| 390 | public function enqueue_scripts() { |
||
| 391 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
||
| 392 | |||
| 393 | $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
||
| 394 | wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
||
| 395 | wp_enqueue_style( 'wpinv_front_style' ); |
||
| 396 | |||
| 397 | // Register scripts |
||
| 398 | wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
||
| 399 | wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
||
| 400 | |||
| 401 | $localize = array(); |
||
| 402 | $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
||
| 403 | $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
||
| 404 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
||
| 405 | $localize['currency_pos'] = wpinv_currency_position(); |
||
| 406 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
||
| 407 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
||
| 408 | $localize['decimals'] = wpinv_decimals(); |
||
| 409 | $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
||
| 410 | $localize['UseTaxes'] = wpinv_use_taxes(); |
||
| 411 | $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
||
| 412 | $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
||
| 413 | $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
||
| 414 | |||
| 415 | $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
||
| 416 | |||
| 417 | wp_enqueue_script( 'jquery-blockui' ); |
||
| 418 | $autofill_api = wpinv_get_option('address_autofill_api'); |
||
| 419 | $autofill_active = wpinv_get_option('address_autofill_active'); |
||
| 420 | if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
||
| 421 | if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
||
| 422 | wp_dequeue_script( 'google-maps-api' ); |
||
| 423 | } |
||
| 424 | wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
||
| 425 | wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
||
| 426 | } |
||
| 427 | |||
| 428 | wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
||
| 429 | wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
||
| 430 | |||
| 431 | wp_enqueue_script( 'wpinv-front-script' ); |
||
| 432 | wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
||
| 433 | |||
| 434 | $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
||
| 435 | wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
||
| 436 | } |
||
| 437 | |||
| 438 | public function wpinv_actions() { |
||
| 439 | if ( isset( $_REQUEST['wpi_action'] ) ) { |
||
| 440 | do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
||
| 441 | } |
||
| 442 | } |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Fires an action after verifying that a user can fire them. |
||
| 446 | * |
||
| 447 | * Note: If the action is on an invoice, subscription etc, esure that the |
||
| 448 | * current user owns the invoice/subscription. |
||
| 449 | */ |
||
| 450 | public function maybe_do_authenticated_action() { |
||
| 455 | } |
||
| 456 | |||
| 457 | } |
||
| 458 | |||
| 459 | public function pre_get_posts( $wp_query ) { |
||
| 460 | if ( ! is_admin() && !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() ) { |
||
| 461 | $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
||
| 462 | } |
||
| 463 | |||
| 464 | return $wp_query; |
||
| 465 | } |
||
| 466 | |||
| 467 | public function bp_invoicing_init() { |
||
| 468 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
||
| 469 | } |
||
| 470 | |||
| 471 | /** |
||
| 472 | * Register widgets |
||
| 473 | * |
||
| 474 | */ |
||
| 475 | public function register_widgets() { |
||
| 491 | } |
||
| 492 | |||
| 493 | } |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Remove our pages from yoast sitemaps. |
||
| 497 | * |
||
| 498 | * @since 1.0.19 |
||
| 499 | * @param int[] $excluded_posts_ids |
||
| 500 | */ |
||
| 501 | public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
||
| 530 | |||
| 531 | } |
||
| 532 | |||
| 533 | public function wp_footer() { |
||
| 534 | echo ' |
||
| 535 | <div class="bsui"> |
||
| 536 | <div id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog"> |
||
| 537 | <div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;"> |
||
| 538 | <div class="modal-content"> |
||
| 548 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.