base_addon_class_name = bd_get_addon_class_name( $this->base_addon ); } else { $this->base_addon_class_name = $addon_class_name; } if ( class_exists( $this->base_addon_class_name ) ) { // Ugly workaround, since we need to support PHP 5.2 $this->base_addon_obj = call_user_func( array( $this->base_addon_class_name, 'factory' ) ); return true; } else { add_action( 'admin_notices', array( $this, 'addon_missing_notice' ) ); return false; } } /** * Show a notice if the base addon is not available. * * @since 5.5 */ public function addon_missing_notice() { $campaign_args = array( 'utm_source' => 'wpadmin', 'utm_campaign' => 'BulkDelete', 'utm_medium' => 'header-notice', 'utm_content' => $this->addon_code, ); $addon_url = bd_get_addon_url( $this->base_addon, $campaign_args ); printf( '

%s

', sprintf( __( '"%s" addon requires "%s" addon to be installed and activated!', 'bulk-delete' ), $this->addon_name, $addon_url , $this->base_addon ) ); } /** * Setup hooks. * * @since 5.5 */ protected function setup_hooks() { add_filter( 'bd_javascript_array', array( $this, 'filter_js_array' ) ); $cron_hook = $this->get_cron_hook(); if ( ! empty( $cron_hook ) ) { add_action( $cron_hook, array( $this, 'do_delete' ), 10, 1 ); } } /** * Filter JS Array and add pro hooks. * * @since 5.5 * * @param array $js_array JavaScript Array * * @return array Modified JavaScript Array */ public function filter_js_array( $js_array ) { $js_array['pro_iterators'][] = $this->get_module()->get_field_slug(); return $js_array; } /** * Hook handler. * * @since 5.5 * * @param array $delete_options */ public function do_delete( $delete_options ) { do_action( 'bd_before_scheduler', $this->addon_name ); $count = $this->get_module()->delete( $delete_options ); do_action( 'bd_after_scheduler', $this->addon_name, $count ); } /** * Get the cron hook. * * @access protected * * @since 5.5 * * @return string Cron hook. */ protected function get_cron_hook() { $cron_hook = ''; if ( null != $this->base_addon_obj ) { $cron_hook = $this->base_addon_obj->get_cron_hook(); } return $cron_hook; } /** * Get base module. * * @access protected * * @since 5.5 * * @return object Base module object */ protected function get_module() { if ( $this->no_base_addon ) { return $this->base_addon_obj; } else { return $this->base_addon_obj->get_module(); } } }