forked from ahmedkaludi/ads-for-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ads-for-wp.php
199 lines (156 loc) · 9.66 KB
/
ads-for-wp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/*
Plugin Name: Ads for WP - Advanced Ads & Adsense Solution for WP & AMP
Plugin URI: https://wordpress.org/plugins/ads-for-wp/
Description: ADs for WP is an Advanced Ad Inserter solution built for WordPress & AMP. Easy to Use, Unlimited Incontent Ads, Adsense, Premium Features and more
Version: 1.9.12
Author: Magazine3
Author URI: http://adsforwp.com/
Donate link: https://www.paypal.me/Kaludi/25usd
Text Domain: ads-for-wp
Domain Path: /languages
License: GPL2+
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
define('ADSFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
define('ADSFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
define('ADSFORWP_PLUGIN_BASENAME', plugin_basename(__FILE__));
define( 'ADSFORWP_LIB_PATH', dirname( __FILE__ ) . '/admin/inc/' );
if ( ! defined( 'ADSFORWP_VERSION' ) ) {
define( 'ADSFORWP_VERSION', '1.9.12' );
}
/* Loading Backend files files*/
require_once ADSFORWP_PLUGIN_DIR.'/admin/ads-setup.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/control-center.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/ads-newsletter.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/ads-widget.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/common-functions.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/settings.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/inc/analytics-settings.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/inc/analytics-common-functions.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/ajax-selectbox.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/file-creation.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/analytics-settings.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/analytics.php';
require_once ADSFORWP_PLUGIN_DIR.'/admin/inc/gutenberg/adsforwp-gutenberg.php';
/* Loading view Metaboxes*/
require_once ADSFORWP_PLUGIN_DIR.'/view/ads-type.php';
require_once ADSFORWP_PLUGIN_DIR.'/view/display.php';
require_once ADSFORWP_PLUGIN_DIR.'/view/ads-visibility.php';
require_once ADSFORWP_PLUGIN_DIR.'/view/ad-groups.php';
require_once ADSFORWP_PLUGIN_DIR.'/view/ads-expire.php';
require_once ADSFORWP_PLUGIN_DIR.'/view/placement.php';
require_once ADSFORWP_PLUGIN_DIR.'/view/visitor-condition.php';
/* Loading frontend files*/
require_once ADSFORWP_PLUGIN_DIR.'/output/functions.php';
require_once ADSFORWP_PLUGIN_DIR.'/output/service.php';
require_once ADSFORWP_PLUGIN_DIR.'/output/amp-condition-display.php';
register_activation_hook( __FILE__, 'adsforwp_on_activation' );
/* Function to check other plugin is install or not*/
function adsforwp_check_plugin() {
if (get_option('adsforwp_do_activation_redirect', false)) {
delete_option('adsforwp_do_activation_redirect');
if(!isset($_GET['activate-multi']))
{
$url = esc_url( admin_url( 'edit.php?post_type=adsforwp' ) );
wp_redirect($url);
exit;
}
}
if ( is_plugin_active('accelerated-mobile-pages/accelerated-moblie-pages.php') ) {
require ADSFORWP_PLUGIN_DIR.'/view/amp-compatibility.php';
}
}
add_action( 'admin_init', 'adsforwp_check_plugin' );
function adsforwp_action_links ( $links ) {
$mylinks = array(
'<a href="' . esc_url(admin_url( 'edit.php?post_type=adsforwp&page=adsforwp' )) . '">'.esc_html__('Settings', 'ads-for-wp').'</a>',
);
return array_merge( $links, $mylinks );
}
add_filter( 'plugin_action_links_' . ADSFORWP_PLUGIN_BASENAME, 'adsforwp_action_links' );
/**
* Set user defined message on plugin activate
*/
function adsforwp_admin_notice(){
/* Check transient, if available display notice */
if( get_transient( 'adsforwp_admin_notice_transient' ) ){
echo '<div class="updated notice is-dismissible message notice notice-alt adsforwp-setup-notice">
<p><span class="dashicons dashicons-thumbs-up"></span>'.esc_html__('Thank you for using Ads For WP plugin!', 'ads-for-wp').'
<a href="'.esc_url( admin_url( 'edit.php?post_type=adsforwp' ) ).'"> '.esc_html__('Start adding ads', 'ads-for-wp') .'</a>
</p></div>';
/* Delete transient, only display this notice once. */
delete_transient( 'adsforwp_admin_notice_transient' );
}
//Feedback notice
$activation_date = get_option("adsforwp_activation_date");
$one_day = date('Y-m-d',strtotime("+1 day", strtotime($activation_date)));
$seven_days = date('Y-m-d',strtotime("+7 day", strtotime($activation_date)));
$one_month = date('Y-m-d',strtotime("+30 day", strtotime($activation_date)));
$sixty_days = date('Y-m-d',strtotime("+60 day", strtotime($activation_date)));
$six_month = date('Y-m-d',strtotime("+180 day", strtotime($activation_date)));
$one_year = date('Y-m-d',strtotime("+365 day", strtotime($activation_date)));
$current_date = date("Y-m-d");
$list_of_date = array($one_day, $seven_days, $one_month, $sixty_days, $six_month, $one_year);
$review_notice_bar_status_date = get_option( "review_notice_bar_close_date");
$review_notice_bar_never = get_option( "adsforwp_review_never");
if(in_array($current_date,$list_of_date) && $review_notice_bar_status_date !=$current_date && $review_notice_bar_never !='never'){
echo '<div class="updated notice is-dismissible message notice notice-alt adsforwp-feedback-notice">
<p><span class="dashicons dashicons-thumbs-up"></span>
'.esc_html__('You have been using the Ads For WP plugin for some time now, do you like it?, If so,', 'ads-for-wp').'
<a target="_blank" href="https://wordpress.org/plugins/ads-for-wp/#reviews">
'.esc_html__('please write us a review', 'ads-for-wp').'
</a>
<button style="margin-left:10px;" class="button button-primary adsforwp-feedback-notice-remindme">'.esc_html__('Remind Me Later', 'ads-for-wp').'</button>
<button style="margin-left:10px;" class="button button-primary adsforwp-feedback-notice-close">'.esc_html__('No Thanks', 'ads-for-wp').'</button> '
. ' </p> </div>';
}
}
add_action( 'admin_notices', 'adsforwp_admin_notice' );
/**
* This function allows you to track usage of your plugin
* Place in your main plugin file
* Refer to https://wisdomplugin.com/support for help
*/
if( ! class_exists( 'Adsforwp_Plugin_Usage_Tracker') ) {
require_once dirname( __FILE__ ) . '/tracking/class-adsforwp-plugin-usage-tracker.php';
}
if( ! function_exists( 'ads_for_wp_start_plugin_tracking' ) ) {
function ads_for_wp_start_plugin_tracking() {
$settings = get_option( 'adsforwp_settings');
$wisdom = new Adsforwp_Plugin_Usage_Tracker(
__FILE__,
'http://45.32.224.83',
(array) $settings,
true,
true,
0
);
}
ads_for_wp_start_plugin_tracking();
}
/**
* Here, We are adding support forum links, hire us links and review links for our plugin inside plugins list
* @param type $meta_fields
* @param type $file
* @return string
*/
function adsforwp_add_plugin_meta_links($meta_fields, $file) {
if ( ADSFORWP_PLUGIN_BASENAME == $file ) {
$plugin_url = "https://wordpress.org/support/plugin/ads-for-wp";
$hire_url = "https://ampforwp.com/hire/";
$meta_fields[] = "<a href='" . esc_url($plugin_url) . "' target='_blank'>" . esc_html__('Support Forum', 'ads-for-wp') . "</a>";
$meta_fields[] = "<a href='" . esc_url($hire_url) . "' target='_blank'>" . esc_html__('Hire Us', 'ads-for-wp') . "</a>";
$meta_fields[] = "<a href='" . esc_url($plugin_url) . "/reviews#new-post' target='_blank' title='" . esc_html__('Rate', 'ads-for-wp') . "'>
<i class='adsforwp-wdi-rate-stars'>"
. "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
. "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
. "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
. "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
. "<svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-star'><polygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2'/></svg>"
. "</i></a>";
}
return $meta_fields;
}
add_filter('plugin_row_meta' , 'adsforwp_add_plugin_meta_links', 10, 2);