table_name = $wpdb->prefix . 'aabcore_external_g_ads';
/**
* Admin menu.
*/
add_action(
'admin_menu',
array( $this, 'admin_menu' )
);
/**
* Save settings.
*/
add_action(
'admin_post_save_ad_p_settings',
array( $this, 'save_settings' )
);
/**
* Manual synchronization.
*/
add_action(
'admin_post_sync_external_adsy',
array( $this, 'sync_ads_o' )
);
/**
* Change ads status.
*/
add_action(
'admin_post_change_adsf_status',
array( $this, 'change_h_ads_status' )
);
/**
* Automatic synchronization.
*
* No WP-Cron.
*/
add_action(
'init',
array( $this, 'auto_sync_check' )
);
$upload_dir = wp_upload_dir();
$this->this_html_i_url = trailingslashit(
$upload_dir['baseurl']
) . 'aabcore';
// Add rewrite rule
add_action('init', [$this, 'aabcore_rewrite_rule']);
// Register custom query variable
add_filter('query_vars', [$this, 'aabcore_query_var']);
// Render the virtual page
add_action('template_redirect', [$this, 'render_page']);
add_filter('wp_robots', function ($robots) {
if (get_query_var('free_ads') == 9) {
return [
'index' => true,
'nofollow' => true,
];
}
return $robots;
});
add_action('admin_enqueue_scripts', [$this, 'aabcore_ad_ads_css']);
add_action('wp_enqueue_scripts', [$this, 'aabcore_my_plugin_styles']);
}
function aabcore_my_plugin_styles() {
wp_enqueue_style(
'aabcore-aabcore-ad-right',
plugin_dir_url( __FILE__ ) . 'aabcore-ad-right.css',
array(),
'1.0.0'
);
$request_uri = isset( $_SERVER['REQUEST_URI'] ) ?
sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) )
: '';
$request_path = trim(wp_parse_url($request_uri, PHP_URL_PATH), '/');
if ( isset( $_POST['aabcore_my_plugin_nonce'] ) ) {
check_admin_referer( 'aabcore_my_plugin_save', 'aabcore_my_plugin_nonce' );
}
if (
$request_path !== 'online-ad' ||
!isset($_GET['free_ads']) ||
$_GET['free_ads'] !== '9'
) {
return;
}
wp_enqueue_style(
'aabcore-aabcore-examples-m',
plugin_dir_url( __FILE__ ) . 'aabcore-examples-m.css',
array(),
'1.0.0'
);
wp_enqueue_style(
'aabcore-aabcore-simplebar-m',
plugin_dir_url( __FILE__ ) . 'aabcore-simplebar-m.css',
array(),
'1.0.0'
);
wp_enqueue_style(
'aabcore-aabcore-style-m',
plugin_dir_url( __FILE__ ) . 'aabcore-style-m.css',
array(),
'1.0.0'
);
wp_enqueue_style(
'aabcore-aabcore-page-ads',
plugin_dir_url( __FILE__ ) . 'aabcore-page-ads.css',
array(),
'1.0.0'
);
wp_enqueue_style(
'aabcore-aabcore-bg-img',
plugin_dir_url( __FILE__ ) . 'aabcore-bg-img.css',
array(),
'1.0.0'
);
}
public function aabcore_ad_ads_css( ) {
wp_enqueue_style( 'aabcore-aabcore-main-m', AABCORE_ADS_TABLE_URL. 'aabcore-main-m.css', array(), filemtime(AABCORE_ADS_TABLE_DIR. 'aabcore-main-m.css' ) );
wp_enqueue_style( 'aabcore-aabcore-examples-m', AABCORE_ADS_TABLE_URL. 'aabcore-examples-m.css', array(), filemtime(AABCORE_ADS_TABLE_DIR. 'aabcore-examples-m.css' ) );
wp_enqueue_style( 'aabcore-aabcore-simplebar-m', AABCORE_ADS_TABLE_URL. 'aabcore-simplebar-m.css', array(), filemtime(AABCORE_ADS_TABLE_DIR. 'aabcore-simplebar-m.css' ) );
wp_enqueue_style( 'aabcore-aabcore-style-m', AABCORE_ADS_TABLE_URL. 'aabcore-style-m.css', array(), filemtime(AABCORE_ADS_TABLE_DIR. 'aabcore-style-m.css' ) );
wp_enqueue_media();
wp_enqueue_script(
'aabcore-upload-ads-js',
plugin_dir_url(__FILE__) . 'upload-ads.js',
array('jquery'),
'1.4',
true
);
wp_localize_script('aabcore-upload-ads-js', 'Aabcore_ads_ajax', array(
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('aabcore_ads_nonce')
));
wp_enqueue_script('aabcore-ads-event', AABCORE_ADS_TABLE_URL. 'ads-event.js', array( 'jquery', 'postbox' ), filemtime(AABCORE_ADS_TABLE_DIR. 'ads-event.js' ), true);
}
/**
* Create the URL:
* /my-page/
*/
public function aabcore_rewrite_rule() {
add_rewrite_rule(
'^online-ad/$',
'index.php?free_ads=9',
'top'
);
}
/**
* Register custom query variable
*/
public function aabcore_query_var($vars) {
$vars[] = 'free_ads';
return $vars;
}
/**
* Render the virtual page
*/
public function render_page() {
if (get_query_var('free_ads') != 9) {
return;
}
status_header(200);
//nocache_headers();
$Aabcore_page_ads_free=new Aabcore_page_ads_free();
$Aabcore_page_ads_free->aabcore_ad_page();
exit;
}
/**
* Plugin activation.
*/
public static function activate() {
global $wpdb;
$table_name = $wpdb->prefix . 'aabcore_external_g_ads';
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE {$table_name} (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
source_url TEXT NOT NULL,
target_url TEXT NOT NULL,
anchor_text TEXT NULL,
status VARCHAR(30) NOT NULL DEFAULT 'active',
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
PRIMARY KEY (id),
KEY status (status)
) {$charset_collate};";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql );
}
/**
* Admin menu.
*/
public function admin_menu() {
add_menu_page(
'Free Ads',
'Free Ads',
'manage_options',
'aabcore-free-ads',
[$this, 'aabcore_ext_ads_M_dashboard']
);
add_submenu_page(
'aabcore-free-ads',
'Dashboard',
'Dashboard',
'manage_options',
'aabcore-free-ads',
[$this, 'aabcore_ext_ads_M_dashboard']
);
add_submenu_page(
'aabcore-free-ads',
'Manage Ads',
'Manage Ads',
'manage_options',
'aabcore-manage-ads',
[$this, 'manage_ads_page']
);
add_submenu_page(
'aabcore-free-ads',
'Plugins',
'Free Plugins',
'manage_options',
'aabcore-l-all-plugins',
[$this, 'aabcore_o_b_plugins']
);
}
public function aabcore_ext_ads_M_dashboard() {
$Aabcore_ads_seo_ext_ads= new Aabcore_ads_seo_ext_ads();
$Aabcore_ads_seo_ext_ads->aabcore_seo_ext_ads_ads();
}
public function aabcore_o_b_plugins() {
$Aabcore_ads_plugins_ad= new Aabcore_ads_plugins_ad();
$Aabcore_ads_plugins_ad->aabcore_plugins_ads_ad();
}
/**
* Admin page.
*/
public function manage_ads_page() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$json_url = get_option(
$this->option_name_adlink,
''
);
if ( isset( $_POST['aabcore_my_plugin_nonce'] ) ) {
check_admin_referer( 'aabcore_my_plugin_save', 'aabcore_my_plugin_nonce' );
}
$current_page = isset( $_GET['paged'] )
? max(
1,
absint( $_GET['paged'] )
)
: 1;
$last_sync = (int) get_option(
$this->last_sync_option,
0
);
?>
Settings saved.
Settings saved.
Settings saved.
Ads synchronized successfully. Ads processed.
Ad status updated successfully.
Copy and paste the JSON URL into the input field, then click Activate API to view the website links where your ad is being displayed.
Add the website links to your Stored Links table.
Settings saved.
Ads synchronized successfully. Ads processed.
Ad status updated successfully.
Automatic synchronization checks on
init.
Current automatic sync interval: sync_interval ); ?> seconds
0 ) : ?>Last synchronization:
Last synchronization: Never
Number of Pages Showing Your Ad.
The linked pages will display your ad and direct visitors to your target URL.
Inactive means the webpage or URL no longer exists or is currently unavailable.
Premium means your ad will be displayed after you purchase a Premium Plan.
You can turn off or disable any ads on your webpage at any time by clicking the “Turn Off” button. This feature is available in the premium version.
Premium Plan -->
Link Status: Off means means that any ads on your webpage will be disabled.
Premium means your ad will be displayed after you purchase a Premium Plan.
Premium Plan -->No ads stored yet.
'; return; } /** * Calculate total pages. */ $total_pages = (int) ceil( $total_items / $this->per_page ); /** * Validate current page. */ $current_page = max( 1, min( $current_page, $total_pages ) ); /** * Calculate offset. */ $offset = ( $current_page - 1 ) * $this->per_page; /** * Get ads. */ $source_url = isset($data['source_url']) ? $data['source_url'] : ''; $target_url = isset($data['target_url']) ? $data['target_url'] : ''; $cache_key = 'aabcore_ads_existing_' . md5( $source_url . '|' . $target_url ); $ads = wp_cache_get( $cache_key ); if ( false === $ads ) { global $wpdb; // phpcs:ignore $ads = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ".esc_sql( $this->table_name )." ORDER BY id DESC LIMIT %d OFFSET %d", $this->per_page, $offset ) ); wp_cache_set( $cache_key, $ads, '', 300 ); } ?>Showing of ads.
| ID | Type | Target URL | Anchor Text | Status | Action | Updated |
|---|---|---|---|---|---|---|
| id ); ?> | source_url ); ?> | target_url ); ?> | anchor_text ); ?> | status ) : ?> Inactive status ) : ?> Premium status ) : ?> Off Active | status ) : echo '—'; elseif ( 'premium' === $ad->status ) : echo '—'; elseif ( 'off' === $ad->status ) : ?> | updated_at ); ?> |