* @since 1.x.x */ class Advanced_Ads_Overview_Widgets_Callbacks { /** * In case one wants to inject several dashboards into a page, we will prevent executing redundant javascript * with the help of this little bool * * @var mixed */ private static $processed_adsense_stats_js = false; /** * When doing ajax request (refreshing the dashboard), we need to have a nonce. * one is enough, that's why we need to remember it. * * @var mixed */ private static $gadsense_dashboard_nonce = false; /** * Register the plugin overview widgets * * @return void */ public static function setup_overview_widgets() { // initiate i18n notice. ( new Translation_Promo( [ 'textdomain' => 'advanced-ads', 'plugin_name' => 'Advanced Ads', 'hook' => 'advanced-ads-overview-below-support', 'glotpress_logo' => false, // disables the plugin icon so we don’t need to keep up with potential changes. ] ) ); // show errors. if ( Advanced_Ads_Ad_Health_Notices::notices_enabled() ) { self::add_meta_box( 'advads_overview_notices', __( 'Notifications', 'advanced-ads' ), 'right', 'render_notices' ); } self::add_meta_box( 'advads_overview_news', __( 'Next Steps', 'advanced-ads' ), 'left', 'render_next_steps' ); self::add_meta_box( 'advads_overview_support', __( 'Manual & Support', 'advanced-ads' ), 'right', 'render_support' ); if ( Utils::can_show_stats() ) { $disable_link_markup = '' . esc_attr__( 'Disable', 'advanced-ads' ) . ''; self::add_meta_box( 'advads_overview_adsense_stats', __( 'AdSense Earnings', 'advanced-ads' ) . $disable_link_markup, 'full', 'render_adsense_stats' ); } // add widgets for pro add ons. self::add_meta_box( 'advads_overview_addons', __( 'Add-Ons', 'advanced-ads' ), 'full', 'render_addons' ); do_action( 'advanced-ads-overview-widgets-after' ); } /** * Loads a meta box into output * * @param string $id meta box ID. * @param string $title title of the meta box. * @param string $position context in which to show the box. * @param string $callback name of the method in Advanced_Ads_Overview_Widgets_Callbacks that fills the box. * * @return void */ public static function add_meta_box( $id, $title, $position, $callback ) { ob_start(); call_user_func( [ 'Advanced_Ads_Overview_Widgets_Callbacks', $callback ] ); do_action( 'advanced-ads-overview-widget-content-' . $id, $id ); $content = ob_get_clean(); include ADVADS_ABSPATH . 'admin/views/overview-widget.php'; } /** * Render Ad Health notices widget * * @return void */ public static function render_notices() { Advanced_Ads_Ad_Health_Notices::get_instance()->render_widget(); ?> get_data()->is_valid() ) { wp_send_json_success( [ 'html' => $report->get_markup() ] ); } if ( $report->refresh_report() ) { wp_send_json_success( [ 'html' => $report->get_markup() ] ); } $error_message = $report->get_last_api_error(); // Send markup with error info. wp_send_json_success( [ 'html' => '

' . wp_kses_post( $error_message ) . '

' ] ); } /** * Add-ons box * * @param bool $hide_activated if true, hide activated add-ons. * @param bool $is_dashboard whether it is used in the AA dashboard. * * @return void */ public static function render_addons( $hide_activated = false, $is_dashboard = true ) { $box = new \AdvancedAds\Admin\Addon_Box( $hide_activated ); $box->display( $is_dashboard ); } /** * Sort by installed add-ons * * @param array{order: int} $a Argument a. * @param array{order: int} $b Argument b. * * @return int */ protected static function sort_by_order( $a, $b ) { return $a['order'] - $b['order']; } }