Version Description
- Tested with WordPress 4.7.3
- Cleaned up code
Download this release
Release Info
Developer | deb255 |
Plugin | Insert Post Ads |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.6 to 1.1
- _modules/dashboard/css/admin.css +0 -4
- _modules/dashboard/dashboard.php +0 -61
- _modules/dashboard/views/dashboard-nodata.php +0 -10
- _modules/dashboard/views/dashboard.php +0 -28
- _modules/dashboard/views/sidebar-donate.php +0 -44
- insert-post-ads.php +260 -142
- readme.txt +64 -18
- views/dashboard-notices.php +21 -0
- views/settings.php +32 -41
- views/sidebar.php +78 -0
_modules/dashboard/css/admin.css
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
#wpbeginner a { text-decoration: none; }
|
2 |
-
#wpbeginner a.rss { background: url(http://cdn.wpbeginner.com/pluginimages/feed.png) 0 50% no-repeat; padding: 0 15px 0 20px; }
|
3 |
-
#wpbeginner a.email { background: url(http://cdn.wpbeginner.com/pluginimages/email.gif) 0 50% no-repeat; padding: 0 15px 0 20px; }
|
4 |
-
#wpbeginner a.facebook { background: url(http://cdn.wpbeginner.com/pluginimages/facebook.png) 0 50% no-repeat; padding: 0 0 0 20px; }
|
|
|
|
|
|
|
|
_modules/dashboard/dashboard.php
DELETED
@@ -1,61 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Dashboard Widget
|
4 |
-
*/
|
5 |
-
class WPBeginnerDashboardWidget {
|
6 |
-
/**
|
7 |
-
* Constructor
|
8 |
-
*
|
9 |
-
* @param object $plugin Plugin Object (name, displayName, version, folder, url)
|
10 |
-
*/
|
11 |
-
function __construct($plugin) {
|
12 |
-
// Plugin Details
|
13 |
-
$this->dashboard = $plugin;
|
14 |
-
$this->dashboardURL = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
|
15 |
-
|
16 |
-
// Hooks
|
17 |
-
add_action('admin_enqueue_scripts', array(&$this, 'adminScriptsAndCSS'));
|
18 |
-
add_action('wp_dashboard_setup', array(&$this, 'dashboardWidget'));
|
19 |
-
add_action('wp_network_dashboard_setup', array(&$this, 'dashboardWidget'));
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Register and enqueue dashboard CSS
|
24 |
-
*/
|
25 |
-
function adminScriptsAndCSS() {
|
26 |
-
// CSS
|
27 |
-
// This will only enqueue once, despite this hook being called by up to several plugins,
|
28 |
-
// as we have set a single, distinct name
|
29 |
-
wp_enqueue_style('wpbeginner', $this->dashboardURL.'css/admin.css');
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Adds a dashboard widget to output WPBeginner RSS
|
34 |
-
*
|
35 |
-
* Checks if another WPBeginner plugin has already created this widget - if so, doesn't duplicate it
|
36 |
-
*/
|
37 |
-
function dashboardWidget() {
|
38 |
-
global $wp_meta_boxes;
|
39 |
-
|
40 |
-
if (isset($wp_meta_boxes['dashboard']['normal']['core']['wpbeginner'])) return; // Another plugin has already registered this widget
|
41 |
-
wp_add_dashboard_widget('wpbeginner', __('Latest from WPBeginner', $this->dashboard->name), array(&$this, 'outputDashboardWidget'));
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Called by dashboardWidget(), includes dashboard.php to output the Dashboard Widget
|
46 |
-
*/
|
47 |
-
function outputDashboardWidget() {
|
48 |
-
$result = wp_remote_get('http://wpbeginner.com/feed/');
|
49 |
-
if (!is_wp_error($result)) {
|
50 |
-
if ($result['response']['code'] == 200) {
|
51 |
-
$xml = simplexml_load_string($result['body']);
|
52 |
-
$rssPosts = $xml->channel;
|
53 |
-
}
|
54 |
-
|
55 |
-
include_once(WP_PLUGIN_DIR.'/'.$this->dashboard->name.'/_modules/dashboard/views/dashboard.php');
|
56 |
-
} else {
|
57 |
-
include_once(WP_PLUGIN_DIR.'/'.$this->dashboard->name.'/_modules/dashboard/views/dashboard-nodata.php');
|
58 |
-
}
|
59 |
-
}
|
60 |
-
}
|
61 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_modules/dashboard/views/dashboard-nodata.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Dashboard Widget (no RSS data available)
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
<div class="rss-widget">
|
7 |
-
<img src="<?php echo $this->dashboardURL; ?>images/logo.png" class="alignleft" style="margin: 0 10px 0 0;" />
|
8 |
-
<p><?php _e('Thanks for using our plugins - why not check out some of our other amazing Premium WordPress Plugins?'); ?></p>
|
9 |
-
<p><a href="http://www.wpcube.co.uk/?utm_source=wordpress&utm_medium=link&utm_content=dashboard&utm_campaign=general" target="_blank" class="button"><?php _e('Visit WP Cube'); ?></a></p>
|
10 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_modules/dashboard/views/dashboard.php
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Dashboard RSS Feed Widget
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
<div class="rss-widget">
|
7 |
-
<img src="http://cdn.wpbeginner.com/pluginimages/wpbeginner.gif" class="alignright" />
|
8 |
-
|
9 |
-
<ul>
|
10 |
-
<?php
|
11 |
-
foreach ($rssPosts->item as $key=>$rssPost) {
|
12 |
-
?>
|
13 |
-
<li>
|
14 |
-
<a href="<?php echo (string) $rssPost->link; ?>" target="_blank" class="rsswidget"><?php echo (string) $rssPost->title; ?></a>
|
15 |
-
<span class="rss-date"><?php echo date('F j, Y', strtotime($rssPost->pubDate)); ?></span>
|
16 |
-
</li>
|
17 |
-
<?php
|
18 |
-
}
|
19 |
-
?>
|
20 |
-
|
21 |
-
<li>
|
22 |
-
<hr />
|
23 |
-
<a href="http://feeds2.feedburner.com/wpbeginner" class="rss" target="_blank"><?php _e('Subscribe with RSS', $this->dashboard->name); ?></a>
|
24 |
-
<a href="http://www.wpbeginner.com/wordpress-newsletter/" class="email" target="_blank"><?php _e('Subscribe by email', $this->dashboard->name); ?></a>
|
25 |
-
<a href="http://facebook.com/wpbeginner/" class="facebook" target="_blank"><?php _e('Join us on Facebook', $this->dashboard->name); ?></a>
|
26 |
-
</li>
|
27 |
-
</ul>
|
28 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_modules/dashboard/views/sidebar-donate.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Donations Sidebar
|
4 |
-
*/
|
5 |
-
?>
|
6 |
-
<!-- Improve Your Site -->
|
7 |
-
<div class="postbox">
|
8 |
-
<h3 class="hndle">
|
9 |
-
<span><?php _e('Improve Your Site', $this->plugin->name); ?></span>
|
10 |
-
</h3>
|
11 |
-
|
12 |
-
<div class="inside">
|
13 |
-
<p>
|
14 |
-
<?php _e('Want to take your site to the next level? Look behind the scenes of WPBeginner to see what you can do!', $this->plugin->name); ?>
|
15 |
-
</p>
|
16 |
-
|
17 |
-
<a href="http://www.wpbeginner.com/blueprint/" class="button" target="_blank">
|
18 |
-
<?php _e('WPBeginner\'s Blueprint »', $this->plugin->name); ?>
|
19 |
-
</a>
|
20 |
-
</div>
|
21 |
-
</div>
|
22 |
-
|
23 |
-
<!-- Donate -->
|
24 |
-
<div class="postbox">
|
25 |
-
<h3 class="hndle">
|
26 |
-
<span><?php _e('Spread The Word', $this->plugin->name); ?></span>
|
27 |
-
</h3>
|
28 |
-
|
29 |
-
<div class="inside">
|
30 |
-
<p>
|
31 |
-
<?php _e('Want to help make this plugin even better? All donations are used to improve this plugin, so donate $10, $20 or $50 now!', $this->plugin->name); ?>
|
32 |
-
</p>
|
33 |
-
<p>
|
34 |
-
<a href="#" target="_blank">
|
35 |
-
<?php _e('Find out more.', $this->plugin->name); ?>
|
36 |
-
</a>
|
37 |
-
</p>
|
38 |
-
<p>
|
39 |
-
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RK3BGVNS5L4ZW" target="_blank">
|
40 |
-
<img src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" alt="<?php _e('Donate to WPBeginner', $this->plugin->name); ?>">
|
41 |
-
</a>
|
42 |
-
</p>
|
43 |
-
</div>
|
44 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
insert-post-ads.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Insert Post Ads
|
4 |
* Plugin URI: http://www.wpbeginner.com/
|
5 |
-
* Version: 1.
|
6 |
* Author: WPBeginner
|
7 |
* Author URI: http://www.wpbeginner.com/
|
8 |
* Description: Allows you to insert ads after paragraphs of your post content
|
@@ -12,7 +12,7 @@
|
|
12 |
/* Copyright 2014 WPBeginner
|
13 |
|
14 |
This program is free software; you can redistribute it and/or modify
|
15 |
-
it under the terms of the GNU General Public License, version 2, as
|
16 |
published by the Free Software Foundation.
|
17 |
|
18 |
This program is distributed in the hope that it will be useful,
|
@@ -39,45 +39,51 @@ class InsertPostAds {
|
|
39 |
$this->plugin->name = 'insert-post-ads'; // Plugin Folder
|
40 |
$this->plugin->displayName = 'Post Adverts'; // Plugin Name
|
41 |
$this->plugin->posttype = 'insertpostads';
|
42 |
-
$this->plugin->version = '1.
|
43 |
$this->plugin->folder = plugin_dir_path( __FILE__ );
|
44 |
$this->plugin->url = plugin_dir_url( __FILE__ );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
// Dashboard Submodule
|
47 |
-
if (!class_exists('WPBeginnerDashboardWidget')) {
|
48 |
-
require_once($this->plugin->folder.'/_modules/dashboard/dashboard.php');
|
49 |
-
}
|
50 |
-
$this->dashboard = new WPBeginnerDashboardWidget($this->plugin);
|
51 |
-
|
52 |
// Hooks
|
53 |
-
add_action('init', array( &$this, 'registerPostTypes'));
|
54 |
-
add_action('admin_enqueue_scripts', array(&$this, 'adminScriptsAndCSS'));
|
55 |
-
add_action('admin_menu', array(&$this, 'adminPanelsAndMetaBoxes'));
|
56 |
-
add_action('plugins_loaded', array(&$this, 'loadLanguageFiles'));
|
57 |
-
add_action('save_post', array(&$this, 'save'));
|
58 |
-
|
|
|
|
|
|
|
59 |
// Filters
|
60 |
-
add_filter('enter_title_here', array(&$this, 'changeTitlePlaceholder')); // Change title placeholder
|
61 |
-
add_filter('post_updated_messages', array(&$this, 'changeUpdatedMessages')); // Appropriate messages for the post type
|
62 |
-
add_filter('the_content', array(&$this, 'checkAdvertsRequired'));
|
|
|
|
|
63 |
}
|
64 |
-
|
65 |
/**
|
66 |
* Register Custom Post Type
|
67 |
*/
|
68 |
function registerPostTypes() {
|
69 |
-
register_post_type($this->plugin->posttype, array(
|
70 |
'labels' => array(
|
71 |
-
'name' => _x('Post Adverts', 'post type general name'),
|
72 |
-
'singular_name' => _x('Post Advert', 'post type singular name'),
|
73 |
-
'add_new' => _x('Add New', 'insertpostads'),
|
74 |
-
'add_new_item' => __('Add New Post Advert'),
|
75 |
-
'edit_item' => __('Edit Post Advert'),
|
76 |
-
'new_item' => __('New Post Advert'),
|
77 |
-
'view_item' => __('View Post Adverts'),
|
78 |
-
'search_items' => __('Search Post Adverts'),
|
79 |
-
'not_found' => __('No post adverts found'),
|
80 |
-
'not_found_in_trash' => __('No post adverts found in Trash'),
|
81 |
'parent_item_colon' => ''
|
82 |
),
|
83 |
'description' => 'Post Adverts',
|
@@ -92,8 +98,26 @@ class InsertPostAds {
|
|
92 |
'hierarchical' => false,
|
93 |
'has_archive' => false,
|
94 |
'show_in_nav_menus' => false,
|
95 |
-
'supports' => array('title'),
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
|
99 |
/**
|
@@ -102,256 +126,287 @@ class InsertPostAds {
|
|
102 |
function adminScriptsAndCSS() {
|
103 |
// JS
|
104 |
// wp_enqueue_script($this->plugin->name.'-admin', $this->plugin->url.'js/admin.js', array('jquery'), $this->plugin->version, true);
|
105 |
-
|
106 |
// CSS
|
107 |
-
wp_enqueue_style($this->plugin->name.'-admin', $this->plugin->url.'css/admin.css', array(), $this->plugin->version);
|
108 |
}
|
109 |
-
|
110 |
/**
|
111 |
* Register the plugin settings panel
|
112 |
*/
|
113 |
function adminPanelsAndMetaBoxes() {
|
114 |
-
add_submenu_page('edit.php?post_type='.$this->plugin->posttype, __('Settings', $this->plugin->name), __('Settings', $this->plugin->name), 'manage_options', $this->plugin->name, array(&$this, 'adminPanel'));
|
115 |
-
add_meta_box('ipa_meta', __('Advert Code', $this->plugin->name), array( &$this, 'displayMetaBox'), $this->plugin->posttype, 'normal', 'high');
|
116 |
-
$postTypes = get_post_types(array(
|
117 |
'public' => true,
|
118 |
-
), 'objects');
|
119 |
-
if ($postTypes) {
|
120 |
-
foreach ($postTypes as $postType) {
|
121 |
// Skip attachments
|
122 |
-
if ($postType->name == 'attachment') {
|
123 |
continue;
|
124 |
}
|
125 |
-
|
126 |
// Skip our CPT
|
127 |
-
if ($postType->name == $this->plugin->posttype) {
|
128 |
continue;
|
129 |
}
|
130 |
-
add_meta_box('ipa_meta', __($this->plugin->displayName, $this->plugin->name), array( &$this, 'displayOptionsMetaBox'), $postType->name, 'normal', 'high');
|
131 |
}
|
132 |
}
|
133 |
-
|
134 |
}
|
135 |
-
|
136 |
/**
|
137 |
* Output the Administration Panel
|
138 |
* Save POSTed data from the Administration Panel into a WordPress option
|
139 |
*/
|
140 |
function adminPanel() {
|
|
|
|
|
|
|
|
|
|
|
141 |
// Save Settings
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
-
|
149 |
-
|
150 |
// Get latest settings
|
151 |
-
$this->settings = get_option($this->plugin->name);
|
152 |
-
|
153 |
// Load Settings Form
|
154 |
-
include_once(
|
155 |
}
|
156 |
-
|
157 |
/**
|
158 |
* Loads plugin textdomain
|
159 |
*/
|
160 |
function loadLanguageFiles() {
|
161 |
-
load_plugin_textdomain($this->plugin->name, false, $this->plugin->name.'/languages/');
|
162 |
}
|
163 |
-
|
164 |
/**
|
165 |
* Displays the meta box on the Custom Post Type
|
166 |
*
|
167 |
* @param object $post Post
|
168 |
*/
|
169 |
-
function displayMetaBox($post) {
|
170 |
// Get meta
|
171 |
-
$adCode = get_post_meta($post->ID, '_ad_code', true);
|
172 |
-
$adPosition = get_post_meta($post->ID, '_ad_position', true);
|
173 |
-
$paragraphNumber = get_post_meta($post->ID, '_paragraph_number', true);
|
174 |
-
|
175 |
// Nonce field
|
176 |
-
wp_nonce_field($this->plugin->name, $this->plugin->name.'_nonce');
|
177 |
?>
|
178 |
<p>
|
179 |
-
<textarea name="ad_code" id="ad_code" style="width: 100%; height: 100px; font-family: Courier; font-size: 12px;"><?php echo $adCode; ?></textarea>
|
180 |
</p>
|
181 |
<p>
|
182 |
-
<label for="ad_position"><?php _e('Display the advert:', $this->plugin->name); ?></label>
|
183 |
<select name="ad_position" size="1">
|
184 |
-
<option value="top"<?php echo (($adPosition == 'top') ? ' selected' : ''); ?>><?php _e('Before Content', $this->plugin->name); ?></option>
|
185 |
-
<option value=""<?php echo (($adPosition == '') ? ' selected' : ''); ?>><?php _e('After Paragraph Number', $this->plugin->name); ?></option>
|
186 |
-
<option value="bottom"<?php echo (($adPosition == 'bottom') ? ' selected' : ''); ?>><?php _e('After Content', $this->plugin->name); ?></option>
|
187 |
</select>
|
188 |
<input type="number" name="paragraph_number" value="<?php echo $paragraphNumber; ?>" min="1" max="999" step="1" id="paragraph_number" />
|
189 |
</p>
|
190 |
<?php
|
191 |
}
|
192 |
-
|
193 |
/**
|
194 |
* Displays the meta box on Pages, Posts and CPTs
|
195 |
*
|
196 |
* @param object $post Post
|
197 |
*/
|
198 |
-
function displayOptionsMetaBox($post) {
|
199 |
// Get meta
|
200 |
-
$disable = get_post_meta($post->ID, '_ipa_disable_ads', true);
|
201 |
-
|
202 |
// Nonce field
|
203 |
-
wp_nonce_field($this->plugin->name, $this->plugin->name.'_nonce');
|
204 |
?>
|
205 |
<p>
|
206 |
-
<label for="ipa_disable_ads"><?php _e('Disable Adverts', $this->plugin->name); ?></label>
|
207 |
-
<input type="checkbox" name="ipa_disable_ads" id="ipa_disable_ads" value="1"<?php echo ($disable ? ' checked' : ''); ?> />
|
208 |
</p>
|
209 |
<p class="description">
|
210 |
-
<?php _e('Check this option if you wish to disable all Post Ads from displaying on this content.', $this->plugin->name); ?>
|
211 |
</p>
|
212 |
<?php
|
213 |
}
|
214 |
-
|
215 |
/**
|
216 |
* Saves the meta box field data
|
217 |
*
|
218 |
* @param int $post_id Post ID
|
219 |
*/
|
220 |
-
function save($post_id) {
|
221 |
// Check if our nonce is set.
|
222 |
-
if (!isset($
|
223 |
-
return $post_id;
|
224 |
}
|
225 |
-
|
226 |
// Verify that the nonce is valid.
|
227 |
-
if (!wp_verify_nonce($
|
228 |
return $post_id;
|
229 |
}
|
230 |
-
|
231 |
// Check the logged in user has permission to edit this post
|
232 |
-
if (!current_user_can('edit_post', $post_id)) {
|
233 |
return $post_id;
|
234 |
}
|
235 |
-
|
236 |
// OK to save meta data
|
237 |
-
if (isset($
|
238 |
-
|
239 |
} else {
|
240 |
-
delete_post_meta($post_id, '_ipa_disable_ads');
|
241 |
}
|
242 |
-
|
243 |
-
if (isset($
|
244 |
-
|
|
|
|
|
245 |
}
|
246 |
-
if (isset($
|
247 |
-
update_post_meta($post_id, '_ad_position', $
|
248 |
}
|
249 |
-
if (isset($
|
250 |
-
update_post_meta($post_id, '_paragraph_number', $
|
251 |
}
|
252 |
}
|
253 |
-
|
254 |
/**
|
255 |
* Changes the 'Enter title here' placeholder on the Ad Custom Post Type
|
256 |
*
|
257 |
* @param string $title Title
|
258 |
* @return string Title
|
259 |
*/
|
260 |
-
function changeTitlePlaceholder($title) {
|
261 |
global $post;
|
262 |
-
if ($post->post_type == $this->plugin->posttype) {
|
263 |
-
$title = __('Advert Title', $this->plugin->name);
|
264 |
}
|
265 |
|
266 |
return $title;
|
267 |
}
|
268 |
-
|
269 |
/**
|
270 |
* Updates the saved, deleted, updated messages when saving an Ad Custom Post Type
|
271 |
*
|
272 |
* @param array $messages Messages
|
273 |
* @return array Messages
|
274 |
*/
|
275 |
-
function changeUpdatedMessages($messages) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
$messages[$this->plugin->posttype] = array(
|
277 |
-
1 =>
|
278 |
-
2 =>
|
279 |
-
3 =>
|
280 |
-
4 =>
|
281 |
-
6 =>
|
282 |
);
|
283 |
|
284 |
return $messages;
|
285 |
}
|
286 |
-
|
287 |
/**
|
288 |
* Checks if the current screen on the frontend needs advert(s) adding to it
|
289 |
*/
|
290 |
-
function checkAdvertsRequired($content) {
|
291 |
global $post;
|
292 |
-
|
293 |
// Settings
|
294 |
-
$this->settings = get_option($this->plugin->name);
|
295 |
-
if (!is_array($this->settings)) {
|
296 |
return $content;
|
297 |
}
|
298 |
-
if (count($this->settings) == 0) {
|
299 |
return $content;
|
300 |
}
|
301 |
-
|
302 |
// Check if we are on a singular post type that's enabled
|
303 |
-
foreach ($this->settings as $postType=>$enabled) {
|
304 |
-
if (is_singular($postType)) {
|
305 |
// Check the post hasn't disabled adverts
|
306 |
-
$disable = get_post_meta($post->ID, '_ipa_disable_ads', true);
|
307 |
-
if (!$disable) {
|
308 |
-
return $this->insertAds($content);
|
309 |
}
|
310 |
}
|
311 |
}
|
312 |
-
|
313 |
return $content;
|
314 |
}
|
315 |
-
|
316 |
/**
|
317 |
* Inserts advert(s) into content
|
318 |
*
|
319 |
* @param string $content Content
|
320 |
* @return string Content
|
321 |
*/
|
322 |
-
function insertAds($content) {
|
323 |
-
$ads = new WP_Query(array(
|
324 |
'post_type' => $this->plugin->posttype,
|
325 |
'post_status' => 'publish',
|
326 |
'posts_per_page' => -1,
|
327 |
-
));
|
328 |
-
if ($ads->have_posts()) {
|
329 |
-
while ($ads->have_posts()) {
|
330 |
$ads->the_post();
|
331 |
-
|
332 |
$adID = get_the_ID();
|
333 |
-
$adCode = get_post_meta($adID, '_ad_code', true);
|
334 |
-
$adPosition = get_post_meta($adID, '_ad_position', true);
|
335 |
-
$paragraphNumber = get_post_meta($adID, '_paragraph_number', true);
|
336 |
-
|
337 |
-
switch ($adPosition) {
|
338 |
case 'top':
|
339 |
-
$content = $adCode
|
340 |
break;
|
341 |
case 'bottom':
|
342 |
-
$content = $content
|
343 |
break;
|
344 |
default:
|
345 |
-
$content = $this->insertAdAfterParagraph($adCode, $paragraphNumber
|
346 |
break;
|
347 |
}
|
348 |
}
|
349 |
}
|
350 |
-
|
351 |
wp_reset_postdata();
|
352 |
return $content;
|
353 |
}
|
354 |
-
|
355 |
/**
|
356 |
* Insert something after a specific paragraph in some content.
|
357 |
*
|
@@ -364,7 +419,7 @@ class InsertPostAds {
|
|
364 |
function insertAdAfterParagraph( $insertion, $paragraph_id, $content ) {
|
365 |
$closing_p = '</p>';
|
366 |
$paragraphs = explode( $closing_p, $content );
|
367 |
-
foreach ($paragraphs as $index => $paragraph) {
|
368 |
// Only add closing tag to non-empty paragraphs
|
369 |
if ( trim( $paragraph ) ) {
|
370 |
// Adding closing markup now, rather than at implode, means insertion
|
@@ -374,12 +429,75 @@ class InsertPostAds {
|
|
374 |
|
375 |
// + 1 allows for considering the first paragraph as #1, not #0.
|
376 |
if ( $paragraph_id == $index + 1 ) {
|
377 |
-
$paragraphs[$index] .= '<div class="'
|
378 |
}
|
379 |
}
|
380 |
return implode( '', $paragraphs );
|
381 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
}
|
383 |
-
|
384 |
$insertPostAds = new InsertPostAds();
|
385 |
?>
|
2 |
/**
|
3 |
* Plugin Name: Insert Post Ads
|
4 |
* Plugin URI: http://www.wpbeginner.com/
|
5 |
+
* Version: 1.1
|
6 |
* Author: WPBeginner
|
7 |
* Author URI: http://www.wpbeginner.com/
|
8 |
* Description: Allows you to insert ads after paragraphs of your post content
|
12 |
/* Copyright 2014 WPBeginner
|
13 |
|
14 |
This program is free software; you can redistribute it and/or modify
|
15 |
+
it under the terms of the GNU General Public License, version 2, as
|
16 |
published by the Free Software Foundation.
|
17 |
|
18 |
This program is distributed in the hope that it will be useful,
|
39 |
$this->plugin->name = 'insert-post-ads'; // Plugin Folder
|
40 |
$this->plugin->displayName = 'Post Adverts'; // Plugin Name
|
41 |
$this->plugin->posttype = 'insertpostads';
|
42 |
+
$this->plugin->version = '1.1';
|
43 |
$this->plugin->folder = plugin_dir_path( __FILE__ );
|
44 |
$this->plugin->url = plugin_dir_url( __FILE__ );
|
45 |
+
$this->plugin->ads_screen_key = $this->plugin->name . '-ads-display-chosen-once';
|
46 |
+
$this->plugin->db_welcome_dismissed_key = $this->plugin->name . '-dashboard-welcome';
|
47 |
+
|
48 |
+
// Check if the global wpb_feed_append variable exists. If not, set it.
|
49 |
+
if ( ! array_key_exists( 'wpb_feed_append', $GLOBALS ) ) {
|
50 |
+
$GLOBALS['wpb_feed_append'] = false;
|
51 |
+
}
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
// Hooks
|
54 |
+
add_action( 'init', array( &$this, 'registerPostTypes' ) );
|
55 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'adminScriptsAndCSS' ) );
|
56 |
+
add_action( 'admin_menu', array( &$this, 'adminPanelsAndMetaBoxes' ) );
|
57 |
+
add_action( 'plugins_loaded', array( &$this, 'loadLanguageFiles' ) );
|
58 |
+
add_action( 'save_post', array( &$this, 'save' ) );
|
59 |
+
add_action( 'wp_feed_options', array( &$this, 'dashBoardRss' ), 10, 2 );
|
60 |
+
add_action( 'admin_notices', array( &$this, 'dashboardNotices' ) );
|
61 |
+
add_action( 'wp_ajax_' . $this->plugin->name . '_dismiss_dashboard_notices', array( &$this, 'dismissDashboardNotices' ) );
|
62 |
+
|
63 |
// Filters
|
64 |
+
add_filter( 'enter_title_here', array( &$this, 'changeTitlePlaceholder' ) ); // Change title placeholder
|
65 |
+
add_filter( 'post_updated_messages', array( &$this, 'changeUpdatedMessages' ) ); // Appropriate messages for the post type
|
66 |
+
add_filter( 'the_content', array( &$this, 'checkAdvertsRequired' ) );
|
67 |
+
add_filter( 'dashboard_secondary_items', array( &$this, 'dashboardSecondaryItems' ) );
|
68 |
+
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( &$this, 'addSettingsLink' ) );
|
69 |
}
|
70 |
+
|
71 |
/**
|
72 |
* Register Custom Post Type
|
73 |
*/
|
74 |
function registerPostTypes() {
|
75 |
+
register_post_type( $this->plugin->posttype, array(
|
76 |
'labels' => array(
|
77 |
+
'name' => _x( 'Post Adverts', 'post type general name' ),
|
78 |
+
'singular_name' => _x( 'Post Advert', 'post type singular name' ),
|
79 |
+
'add_new' => _x( 'Add New', 'insertpostads' ),
|
80 |
+
'add_new_item' => __( 'Add New Post Advert' ),
|
81 |
+
'edit_item' => __( 'Edit Post Advert' ),
|
82 |
+
'new_item' => __( 'New Post Advert' ),
|
83 |
+
'view_item' => __( 'View Post Adverts' ),
|
84 |
+
'search_items' => __( 'Search Post Adverts' ),
|
85 |
+
'not_found' => __( 'No post adverts found' ),
|
86 |
+
'not_found_in_trash' => __( 'No post adverts found in Trash' ),
|
87 |
'parent_item_colon' => ''
|
88 |
),
|
89 |
'description' => 'Post Adverts',
|
98 |
'hierarchical' => false,
|
99 |
'has_archive' => false,
|
100 |
'show_in_nav_menus' => false,
|
101 |
+
'supports' => array( 'title' ),
|
102 |
+
'capabilities' => array(
|
103 |
+
'edit_post' => 'update_core',
|
104 |
+
'delete_post' => 'update_core',
|
105 |
+
'edit_posts' => 'update_core',
|
106 |
+
'edit_others_posts' => 'update_core',
|
107 |
+
'delete_posts' => 'update_core',
|
108 |
+
'publish_posts' => 'update_core',
|
109 |
+
'read_private_posts' => 'update_core'
|
110 |
+
),
|
111 |
+
));
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Add Settings links in the plugin list page
|
116 |
+
*/
|
117 |
+
function addSettingsLink( $links ) {
|
118 |
+
$settings_link = '<a href="' . admin_url( 'edit.php?post_type=' . $this->plugin->posttype . '&page=' . $this->plugin->name ) . '">' . __( 'Settings' ) . '</a>';
|
119 |
+
array_push( $links, $settings_link );
|
120 |
+
return $links;
|
121 |
}
|
122 |
|
123 |
/**
|
126 |
function adminScriptsAndCSS() {
|
127 |
// JS
|
128 |
// wp_enqueue_script($this->plugin->name.'-admin', $this->plugin->url.'js/admin.js', array('jquery'), $this->plugin->version, true);
|
129 |
+
|
130 |
// CSS
|
131 |
+
wp_enqueue_style( $this->plugin->name.'-admin', $this->plugin->url.'css/admin.css', array(), $this->plugin->version );
|
132 |
}
|
133 |
+
|
134 |
/**
|
135 |
* Register the plugin settings panel
|
136 |
*/
|
137 |
function adminPanelsAndMetaBoxes() {
|
138 |
+
add_submenu_page( 'edit.php?post_type='.$this->plugin->posttype, __( 'Settings', $this->plugin->name ), __( 'Settings', $this->plugin->name ), 'manage_options', $this->plugin->name, array( &$this, 'adminPanel' ) );
|
139 |
+
add_meta_box( 'ipa_meta', __( 'Advert Code', $this->plugin->name ), array( &$this, 'displayMetaBox' ), $this->plugin->posttype, 'normal', 'high' );
|
140 |
+
$postTypes = get_post_types( array(
|
141 |
'public' => true,
|
142 |
+
), 'objects' );
|
143 |
+
if ( $postTypes ) {
|
144 |
+
foreach ( $postTypes as $postType ) {
|
145 |
// Skip attachments
|
146 |
+
if ( $postType->name == 'attachment' ) {
|
147 |
continue;
|
148 |
}
|
149 |
+
|
150 |
// Skip our CPT
|
151 |
+
if ( $postType->name == $this->plugin->posttype ) {
|
152 |
continue;
|
153 |
}
|
154 |
+
add_meta_box( 'ipa_meta', __( $this->plugin->displayName, $this->plugin->name ), array( &$this, 'displayOptionsMetaBox' ), $postType->name, 'normal', 'high' );
|
155 |
}
|
156 |
}
|
157 |
+
|
158 |
}
|
159 |
+
|
160 |
/**
|
161 |
* Output the Administration Panel
|
162 |
* Save POSTed data from the Administration Panel into a WordPress option
|
163 |
*/
|
164 |
function adminPanel() {
|
165 |
+
// only admin user can access this page
|
166 |
+
if ( !current_user_can( 'administrator' ) ) {
|
167 |
+
echo '<p>' . __( 'Sorry, you are not allowed to access this page.', $this->plugin->name ) . '</p>';
|
168 |
+
return;
|
169 |
+
}
|
170 |
// Save Settings
|
171 |
+
if ( isset( $_REQUEST['submit'] ) ) {
|
172 |
+
if ( ! wp_verify_nonce( $_REQUEST['_nonce'], $this->plugin->name . '-nonce' ) ) {
|
173 |
+
$this->errorMessage = __( 'Something went wrong. Please try to save again.', $this->plugin->name );
|
174 |
+
} else {
|
175 |
+
delete_option( $this->plugin->name );
|
176 |
+
if ( isset( $_REQUEST[$this->plugin->name] ) ) {
|
177 |
+
// if user save setting contains post or page or anyother cpt, then set an option
|
178 |
+
// that can be used later to let user know about choosing where to
|
179 |
+
// display post ads after first ad is created
|
180 |
+
if( ( count( $_REQUEST[$this->plugin->name] ) == 1 && !isset( $_REQUEST[$this->plugin->name]['css'] ) ) || count( $_REQUEST[$this->plugin->name] ) > 1 ) {
|
181 |
+
update_option( $this->plugin->ads_screen_key, 1 );
|
182 |
+
}
|
183 |
+
// sanitise the array
|
184 |
+
$tempArr = $_REQUEST[$this->plugin->name];
|
185 |
+
unset( $_REQUEST[$this->plugin->name] );
|
186 |
+
foreach( $tempArr as $key => $value ) {
|
187 |
+
$_REQUEST[$this->plugin->name][sanitize_text_field( $key )] = sanitize_text_field( $value );
|
188 |
+
}
|
189 |
+
unset( $tempArr );
|
190 |
+
update_option( $this->plugin->name, $_REQUEST[$this->plugin->name] );
|
191 |
+
}
|
192 |
+
$this->message = __( 'Post Advert Settings Saved.', $this->plugin->name );
|
193 |
}
|
194 |
+
}
|
195 |
+
|
196 |
// Get latest settings
|
197 |
+
$this->settings = get_option( $this->plugin->name );
|
198 |
+
|
199 |
// Load Settings Form
|
200 |
+
include_once( $this->plugin->folder . '/views/settings.php' );
|
201 |
}
|
202 |
+
|
203 |
/**
|
204 |
* Loads plugin textdomain
|
205 |
*/
|
206 |
function loadLanguageFiles() {
|
207 |
+
load_plugin_textdomain( $this->plugin->name, false, $this->plugin->name . '/languages/' );
|
208 |
}
|
209 |
+
|
210 |
/**
|
211 |
* Displays the meta box on the Custom Post Type
|
212 |
*
|
213 |
* @param object $post Post
|
214 |
*/
|
215 |
+
function displayMetaBox( $post ) {
|
216 |
// Get meta
|
217 |
+
$adCode = get_post_meta( $post->ID, '_ad_code', true );
|
218 |
+
$adPosition = get_post_meta( $post->ID, '_ad_position', true );
|
219 |
+
$paragraphNumber = get_post_meta( $post->ID, '_paragraph_number', true );
|
220 |
+
|
221 |
// Nonce field
|
222 |
+
wp_nonce_field( $this->plugin->name, $this->plugin->name . '_nonce' );
|
223 |
?>
|
224 |
<p>
|
225 |
+
<textarea name="ad_code" id="ad_code" style="width: 100%; height: 100px; font-family: Courier; font-size: 12px;"><?php echo esc_html( wp_unslash( $adCode ) ); ?></textarea>
|
226 |
</p>
|
227 |
<p>
|
228 |
+
<label for="ad_position"><?php _e( 'Display the advert:', $this->plugin->name ); ?></label>
|
229 |
<select name="ad_position" size="1">
|
230 |
+
<option value="top"<?php echo ( ( $adPosition == 'top' ) ? ' selected' : '' ); ?>><?php _e( 'Before Content', $this->plugin->name ); ?></option>
|
231 |
+
<option value=""<?php echo ( ( $adPosition == '' ) ? ' selected' : '' ); ?>><?php _e( 'After Paragraph Number', $this->plugin->name ); ?></option>
|
232 |
+
<option value="bottom"<?php echo ( ( $adPosition == 'bottom' ) ? ' selected' : '' ); ?>><?php _e( 'After Content', $this->plugin->name ); ?></option>
|
233 |
</select>
|
234 |
<input type="number" name="paragraph_number" value="<?php echo $paragraphNumber; ?>" min="1" max="999" step="1" id="paragraph_number" />
|
235 |
</p>
|
236 |
<?php
|
237 |
}
|
238 |
+
|
239 |
/**
|
240 |
* Displays the meta box on Pages, Posts and CPTs
|
241 |
*
|
242 |
* @param object $post Post
|
243 |
*/
|
244 |
+
function displayOptionsMetaBox( $post ) {
|
245 |
// Get meta
|
246 |
+
$disable = get_post_meta( $post->ID, '_ipa_disable_ads', true );
|
247 |
+
|
248 |
// Nonce field
|
249 |
+
wp_nonce_field( $this->plugin->name, $this->plugin->name . '_nonce' );
|
250 |
?>
|
251 |
<p>
|
252 |
+
<label for="ipa_disable_ads"><?php _e( 'Disable Adverts', $this->plugin->name ); ?></label>
|
253 |
+
<input type="checkbox" name="ipa_disable_ads" id="ipa_disable_ads" value="1"<?php echo ( $disable ? ' checked' : '' ); ?> />
|
254 |
</p>
|
255 |
<p class="description">
|
256 |
+
<?php _e( 'Check this option if you wish to disable all Post Ads from displaying on this content.', $this->plugin->name ); ?>
|
257 |
</p>
|
258 |
<?php
|
259 |
}
|
260 |
+
|
261 |
/**
|
262 |
* Saves the meta box field data
|
263 |
*
|
264 |
* @param int $post_id Post ID
|
265 |
*/
|
266 |
+
function save( $post_id ) {
|
267 |
// Check if our nonce is set.
|
268 |
+
if ( !isset($_REQUEST[$this->plugin->name . '_nonce'] ) ) {
|
269 |
+
return $post_id;
|
270 |
}
|
271 |
+
|
272 |
// Verify that the nonce is valid.
|
273 |
+
if ( !wp_verify_nonce( $_REQUEST[$this->plugin->name.'_nonce'], $this->plugin->name ) ) {
|
274 |
return $post_id;
|
275 |
}
|
276 |
+
|
277 |
// Check the logged in user has permission to edit this post
|
278 |
+
if ( !current_user_can( 'edit_post', $post_id ) ) {
|
279 |
return $post_id;
|
280 |
}
|
281 |
+
|
282 |
// OK to save meta data
|
283 |
+
if ( isset( $_REQUEST['ipa_disable_ads'] ) ) {
|
284 |
+
update_post_meta( $post_id, '_ipa_disable_ads', sanitize_text_field( $_REQUEST['ipa_disable_ads'] ) );
|
285 |
} else {
|
286 |
+
delete_post_meta( $post_id, '_ipa_disable_ads' );
|
287 |
}
|
288 |
+
|
289 |
+
if ( isset( $_REQUEST['ad_code'] ) ) {
|
290 |
+
// $_REQUEST has already been slashed by wp_magic_quotes in wp-settings
|
291 |
+
// so do nothing before saving
|
292 |
+
update_post_meta( $post_id, '_ad_code', $_REQUEST['ad_code'] );
|
293 |
}
|
294 |
+
if ( isset( $_REQUEST['ad_position'] ) ) {
|
295 |
+
update_post_meta( $post_id, '_ad_position', sanitize_text_field( $_REQUEST['ad_position'] ) );
|
296 |
}
|
297 |
+
if ( isset( $_REQUEST['paragraph_number'] ) ) {
|
298 |
+
update_post_meta( $post_id, '_paragraph_number', sanitize_text_field( $_REQUEST['paragraph_number'] ) );
|
299 |
}
|
300 |
}
|
301 |
+
|
302 |
/**
|
303 |
* Changes the 'Enter title here' placeholder on the Ad Custom Post Type
|
304 |
*
|
305 |
* @param string $title Title
|
306 |
* @return string Title
|
307 |
*/
|
308 |
+
function changeTitlePlaceholder( $title ) {
|
309 |
global $post;
|
310 |
+
if ( $post->post_type == $this->plugin->posttype ) {
|
311 |
+
$title = __( 'Advert Title', $this->plugin->name );
|
312 |
}
|
313 |
|
314 |
return $title;
|
315 |
}
|
316 |
+
|
317 |
/**
|
318 |
* Updates the saved, deleted, updated messages when saving an Ad Custom Post Type
|
319 |
*
|
320 |
* @param array $messages Messages
|
321 |
* @return array Messages
|
322 |
*/
|
323 |
+
function changeUpdatedMessages( $messages ) {
|
324 |
+
$published_msg = __( 'Advert published.', $this->plugin->name );
|
325 |
+
$updated_msg = __( 'Advert updated.', $this->plugin->name );
|
326 |
+
// change the messages for first time user, if where to display ads options are not set
|
327 |
+
if ( !get_option( $this->plugin->ads_screen_key ) ) {
|
328 |
+
$published_msg = sprintf( __( 'Advert published. Now, go to the <a href="%s">settings page</a> to select where you want to display your ads.', $this->plugin->name ), admin_url( 'edit.php?post_type=' . $this->plugin->posttype . '&page=' . $this->plugin->name ) );
|
329 |
+
$updated_msg = sprintf( __( 'Advert updated. Now, go to the <a href="%s">settings page</a> to select where you want to display your ads.', $this->plugin->name ), admin_url( 'edit.php?post_type=' . $this->plugin->posttype . '&page=' . $this->plugin->name ) );
|
330 |
+
}
|
331 |
$messages[$this->plugin->posttype] = array(
|
332 |
+
1 => $updated_msg,
|
333 |
+
2 => $updated_msg,
|
334 |
+
3 => $updated_msg,
|
335 |
+
4 => $updated_msg,
|
336 |
+
6 => $published_msg,
|
337 |
);
|
338 |
|
339 |
return $messages;
|
340 |
}
|
341 |
+
|
342 |
/**
|
343 |
* Checks if the current screen on the frontend needs advert(s) adding to it
|
344 |
*/
|
345 |
+
function checkAdvertsRequired( $content ) {
|
346 |
global $post;
|
347 |
+
|
348 |
// Settings
|
349 |
+
$this->settings = get_option( $this->plugin->name );
|
350 |
+
if ( !is_array( $this->settings ) ) {
|
351 |
return $content;
|
352 |
}
|
353 |
+
if ( count( $this->settings ) == 0 ) {
|
354 |
return $content;
|
355 |
}
|
356 |
+
|
357 |
// Check if we are on a singular post type that's enabled
|
358 |
+
foreach ( $this->settings as $postType=>$enabled ) {
|
359 |
+
if ( is_singular( $postType ) ) {
|
360 |
// Check the post hasn't disabled adverts
|
361 |
+
$disable = get_post_meta( $post->ID, '_ipa_disable_ads', true );
|
362 |
+
if ( !$disable ) {
|
363 |
+
return $this->insertAds( $content );
|
364 |
}
|
365 |
}
|
366 |
}
|
367 |
+
|
368 |
return $content;
|
369 |
}
|
370 |
+
|
371 |
/**
|
372 |
* Inserts advert(s) into content
|
373 |
*
|
374 |
* @param string $content Content
|
375 |
* @return string Content
|
376 |
*/
|
377 |
+
function insertAds( $content ) {
|
378 |
+
$ads = new WP_Query( array(
|
379 |
'post_type' => $this->plugin->posttype,
|
380 |
'post_status' => 'publish',
|
381 |
'posts_per_page' => -1,
|
382 |
+
) );
|
383 |
+
if ( $ads->have_posts() ) {
|
384 |
+
while ( $ads->have_posts() ) {
|
385 |
$ads->the_post();
|
386 |
+
|
387 |
$adID = get_the_ID();
|
388 |
+
$adCode = get_post_meta( $adID, '_ad_code', true );
|
389 |
+
$adPosition = get_post_meta( $adID, '_ad_position', true );
|
390 |
+
$paragraphNumber = get_post_meta( $adID, '_paragraph_number', true );
|
391 |
+
|
392 |
+
switch ( $adPosition ) {
|
393 |
case 'top':
|
394 |
+
$content = $adCode . $content;
|
395 |
break;
|
396 |
case 'bottom':
|
397 |
+
$content = $content . $adCode;
|
398 |
break;
|
399 |
default:
|
400 |
+
$content = $this->insertAdAfterParagraph( $adCode, $paragraphNumber, $content );
|
401 |
break;
|
402 |
}
|
403 |
}
|
404 |
}
|
405 |
+
|
406 |
wp_reset_postdata();
|
407 |
return $content;
|
408 |
}
|
409 |
+
|
410 |
/**
|
411 |
* Insert something after a specific paragraph in some content.
|
412 |
*
|
419 |
function insertAdAfterParagraph( $insertion, $paragraph_id, $content ) {
|
420 |
$closing_p = '</p>';
|
421 |
$paragraphs = explode( $closing_p, $content );
|
422 |
+
foreach ( $paragraphs as $index => $paragraph ) {
|
423 |
// Only add closing tag to non-empty paragraphs
|
424 |
if ( trim( $paragraph ) ) {
|
425 |
// Adding closing markup now, rather than at implode, means insertion
|
429 |
|
430 |
// + 1 allows for considering the first paragraph as #1, not #0.
|
431 |
if ( $paragraph_id == $index + 1 ) {
|
432 |
+
$paragraphs[$index] .= '<div class="' . $this->plugin->name . '"' . ( isset( $this->settings['css'] ) ? '' : ' style="clear:both;float:left;width:100%;margin:0 0 20px 0;"' ) . '>' . $insertion . '</div>';
|
433 |
}
|
434 |
}
|
435 |
return implode( '', $paragraphs );
|
436 |
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Dismiss the welcome notice for the plugin
|
440 |
+
*/
|
441 |
+
function dismissDashboardNotices() {
|
442 |
+
check_ajax_referer( $this->plugin->name . '-nonce', 'nonce' );
|
443 |
+
// user has dismissed the welcome notice
|
444 |
+
update_option( $this->plugin->db_welcome_dismissed_key, 1 );
|
445 |
+
exit;
|
446 |
+
}
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Show relevant notices for the plugin
|
450 |
+
*/
|
451 |
+
function dashboardNotices() {
|
452 |
+
global $typenow;
|
453 |
+
|
454 |
+
// if no ad has been created yet
|
455 |
+
// and page type in not the ads
|
456 |
+
// and the welcome dismissed key is not set, then show a notice
|
457 |
+
$ads_created = get_posts(
|
458 |
+
array(
|
459 |
+
'numberposts' => 1,
|
460 |
+
'post_type' => $this->plugin->posttype,
|
461 |
+
'post_status' => 'publish'
|
462 |
+
)
|
463 |
+
);
|
464 |
+
|
465 |
+
if ( empty( $ads_created ) && $typenow != $this->plugin->posttype && !get_option( $this->plugin->db_welcome_dismissed_key ) ) {
|
466 |
+
// load the notices view
|
467 |
+
include_once( $this->plugin->folder . '/views/dashboard-notices.php' );
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Number of Secondary feed items to show
|
473 |
+
*/
|
474 |
+
function dashboardSecondaryItems() {
|
475 |
+
return 6;
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Update the planet feed to add the WPB feed
|
480 |
+
*/
|
481 |
+
function dashboardRss( $feed, $url ) {
|
482 |
+
// Return early if not on the right page.
|
483 |
+
global $pagenow;
|
484 |
+
if ( 'admin-ajax.php' !== $pagenow ) {
|
485 |
+
return;
|
486 |
+
}
|
487 |
+
|
488 |
+
// Return early if not on the right feed.
|
489 |
+
if ( strpos( $url, 'planet.wordpress.org' ) === false ) {
|
490 |
+
return;
|
491 |
+
}
|
492 |
+
|
493 |
+
// Only move forward if this action hasn't been done already.
|
494 |
+
if ( ! $GLOBALS['wpb_feed_append'] ) {
|
495 |
+
$GLOBALS['wpb_feed_append'] = true;
|
496 |
+
$urls = array( 'http://www.wpbeginner.com/feed/', $url );
|
497 |
+
$feed->set_feed_url( $urls );
|
498 |
+
}
|
499 |
+
}
|
500 |
}
|
501 |
+
|
502 |
$insertPostAds = new InsertPostAds();
|
503 |
?>
|
readme.txt
CHANGED
@@ -1,37 +1,63 @@
|
|
1 |
=== Insert Post Ads ===
|
2 |
-
Contributors: WPbeginner, smub,
|
3 |
Donate link:http://www.wpbeginner.com/wpbeginner-needs-your-help/
|
4 |
-
Tags: ads, adsense, google adsense, insert ads in post, wordpress ads plugin, advertising plugin, banners plugin, post ads
|
5 |
Requires at least: 3.6
|
6 |
-
Tested up to: 4.
|
7 |
Stable tag: trunk
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
20 |
|
21 |
-
|
22 |
|
23 |
-
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
== Installation ==
|
30 |
|
31 |
-
1.
|
32 |
-
2. Active the Insert Post Ads plugin through the
|
33 |
-
3. Add your adverts by navigating to the `Post Adverts` in the WordPress Administration menu
|
34 |
-
4. Choose where to insert your newly created Post Adverts by navigating to `Post Adverts > Settings` in the WordPress Administration menu
|
35 |
|
36 |
[youtube https://www.youtube.com/watch?v=AXM1QgMODW0]
|
37 |
|
@@ -42,10 +68,32 @@ Lastly, if you like this plugin then follow WPBeginner on <a href="http://twitte
|
|
42 |
|
43 |
== Frequently Asked Questions ==
|
44 |
|
|
|
|
|
|
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
== Changelog ==
|
48 |
|
|
|
|
|
|
|
|
|
49 |
= 1.0.5 =
|
50 |
* Tested with WordPress 4.3
|
51 |
* Fix: plugin_dir_path() and plugin_dir_url() used for Multisite / symlink support
|
@@ -67,6 +115,4 @@ Lastly, if you like this plugin then follow WPBeginner on <a href="http://twitte
|
|
67 |
* Added Simplified Chinese language translations (props: Changmeng Hu)
|
68 |
|
69 |
= 1.0 =
|
70 |
-
* First release
|
71 |
-
|
72 |
-
== Upgrade Notice ==
|
1 |
=== Insert Post Ads ===
|
2 |
+
Contributors: WPbeginner, smub, deb255
|
3 |
Donate link:http://www.wpbeginner.com/wpbeginner-needs-your-help/
|
4 |
+
Tags: ad injection, ads, ads plugin, adsense, adsense injection, google adsense, insert ads in post, insert post ads, wordpress ads plugin, advertising plugin, banners plugin, post ads
|
5 |
Requires at least: 3.6
|
6 |
+
Tested up to: 4.7.2
|
7 |
Stable tag: trunk
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Automatically insert post ads after paragraphs of your posts, pages, and custom post types.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
= Ads Plugin With Auto Ad Injection =
|
16 |
|
17 |
+
Need an easy way to automatically insert post ads?
|
18 |
|
19 |
+
In-post ads get the best click through rate. If you want to increase your CTR and Google AdSense revenue, then you need to insert post ads within your content.
|
20 |
|
21 |
+
Insert Post Ads allows you to automatically insert post ads after a specified number of paragraphs. This saves you the hassle of manually inserting post ads for every post.
|
22 |
|
23 |
+
This ads plugin is based on our article about <a href="http://www.wpbeginner.com/wp-tutorials/how-to-insert-ads-within-your-post-content-in-wordpress/" title="How to Insert Ads within your Post Content in WordPress" rel="friend">how to insert ads within your post content in WordPress</a>.
|
24 |
|
25 |
+
We created this plugin to make it as easy as possible to insert ads in posts.
|
26 |
|
27 |
+
= Insert Post Ads Features =
|
28 |
+
|
29 |
+
* Quick and easy setup
|
30 |
+
* Automatic <strong>Google AdSense injection</strong>
|
31 |
+
* Insert post ads using any third party advertising code, or custom code
|
32 |
+
* Select whether to insert post ads on posts, pages, or custom post types.
|
33 |
+
* Choose to insert post ads before content, after post content, or after specified number of paragraphs
|
34 |
+
|
35 |
+
Insert Post Ads makes monetizing your blog easy.
|
36 |
+
|
37 |
+
= Credits =
|
38 |
+
|
39 |
+
This plugin is created by <a href="https://syedbalkhi.com/" rel="friend" title="Syed Balkhi">Syed Balkhi</a> and the <a href="http://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> team.
|
40 |
+
|
41 |
+
= What's Next =
|
42 |
+
|
43 |
+
If you like this plugin, please leave a good rating and consider checking out our other projects:
|
44 |
+
|
45 |
+
* <a href="http://optinmonster.com/" rel="friend" title="OptinMonster">OptinMonster</a> - Get More Email Subscribers
|
46 |
+
* <a href="http://wpforms.com/" rel="friend" title="WPForms">WPForms</a> - Best Contact Form Builder Plugin
|
47 |
+
* <a href="http://soliloquywp.com/" rel="friend" title="Soliloquy">Soliloquy</a> - Best WordPress Slider Plugin
|
48 |
+
* <a href="http://enviragallery.com/" rel="friend" title="Envira Gallery">Envira Gallery</a> - Best WordPress Gallery Plugin
|
49 |
+
* <a href="http://monsterinsights.com/" rel="friend" title="MonsterInsights">MonsterInsights</a> - Best Google Analytics Plugin
|
50 |
+
|
51 |
+
Visit <a href="http://www.wpbeginner.com/" rel="friend" title="WPBeginner">WPBeginner</a> to learn from our <a href="http://www.wpbeginner.com/category/wp-tutorials/" rel="friend" title="WordPress Tutorials">WordPress Tutorials</a> and find out about other <a href="http://www.wpbeginner.com/category/plugins/" rel="friend" title="Best WordPress Plugins">best WordPress plugins</a>.
|
52 |
+
|
53 |
+
This plugin should work with most <a href="http://www.wpbeginner.com/wordpress-hosting/" title="Best WordPress Hosting" rel="friend">good WordPress hosting</a> providers, but if you need help to insert post ads, you can ask your questions here.
|
54 |
|
55 |
== Installation ==
|
56 |
|
57 |
+
1. Install Insert Post Ads by uploading the `insert-post-ads` folder to the `/wp-content/plugins/` directory. (See instructions on <a href="http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/" rel="friend">how to install a WordPress plugin</a>.)
|
58 |
+
2. Active the Insert Post Ads plugin through the `Plugins` menu in WordPress
|
59 |
+
3. Add your adverts by navigating to the `Post Adverts` in the WordPress Administration menu.
|
60 |
+
4. Choose where to insert your newly created Post Adverts by navigating to `Post Adverts > Settings` in the WordPress Administration menu.
|
61 |
|
62 |
[youtube https://www.youtube.com/watch?v=AXM1QgMODW0]
|
63 |
|
68 |
|
69 |
== Frequently Asked Questions ==
|
70 |
|
71 |
+
= Will my post ads be responsive? =
|
72 |
+
|
73 |
+
When you insert post ads, your theme will determine whether or not your post ads are responsive on mobile devices.
|
74 |
|
75 |
+
= Does Insert Post Ads work with custom post types? =
|
76 |
+
|
77 |
+
Yes, you can choose to insert post ads in custom post types in the `Post Adverts > Settings` menu.
|
78 |
+
|
79 |
+
== Notes ==
|
80 |
+
|
81 |
+
Insert Post Ads is the easiest ad injection plugin, for Google AdSense or any advertising code.
|
82 |
+
|
83 |
+
Our goal is to make using WordPress easy for beginners, both with our <a href="http://www.wpbeginner.com/wordpress-plugins/" rel="friend" title="WordPress Plugins">WordPress plugins</a> and resources like <a href="http://www.wpbeginner.com/" rel="friend">WPBeginner</a>, the largest WordPress resource site for beginners.
|
84 |
+
|
85 |
+
I feel that we have done that here. I hope you enjoy using Insert Post Ads.
|
86 |
+
|
87 |
+
Thank you
|
88 |
+
|
89 |
+
Syed Balkhi
|
90 |
|
91 |
== Changelog ==
|
92 |
|
93 |
+
= 1.1 =
|
94 |
+
* Tested with WordPress 4.7.3
|
95 |
+
* Cleaned up code
|
96 |
+
|
97 |
= 1.0.5 =
|
98 |
* Tested with WordPress 4.3
|
99 |
* Fix: plugin_dir_path() and plugin_dir_url() used for Multisite / symlink support
|
115 |
* Added Simplified Chinese language translations (props: Changmeng Hu)
|
116 |
|
117 |
= 1.0 =
|
118 |
+
* First release
|
|
|
|
views/dashboard-notices.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Notices template
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<div class="notice notice-success is-dismissible <?= $this->plugin->name ?>-notice-welcome">
|
7 |
+
<p><?php _e( 'Thank you for installing Insert Ads!', $this->plugin->name ); ?> <a href="<?= esc_url( admin_url( 'post-new.php?post_type=' . $this->plugin->posttype ) ); ?>">Create</a> your first Advert now.</p>
|
8 |
+
</div>
|
9 |
+
<script type="text/javascript">
|
10 |
+
jQuery(document).ready( function($) {
|
11 |
+
$(document).on('click', '.<?= $this->plugin->name ?>-notice-welcome button.notice-dismiss', function( event ) {
|
12 |
+
event.preventDefault();
|
13 |
+
$.post( ajaxurl, {
|
14 |
+
action: '<?= $this->plugin->name . '_dismiss_dashboard_notices' ?>',
|
15 |
+
nonce: '<?= wp_create_nonce( $this->plugin->name . '-nonce' ) ?>'
|
16 |
+
|
17 |
+
});
|
18 |
+
$('.<?= $this->plugin->name ?>-notice-welcome').remove();
|
19 |
+
});
|
20 |
+
});
|
21 |
+
</script>
|
views/settings.php
CHANGED
@@ -1,95 +1,86 @@
|
|
1 |
<div class="wrap">
|
2 |
-
<h2><?php echo $this->plugin->displayName; ?> » <?php _e('Settings', $this->plugin->name); ?></h2>
|
3 |
-
|
4 |
-
<?php
|
5 |
-
if (isset($this->message)) {
|
6 |
?>
|
7 |
-
<div class="updated fade"><p><?php echo $this->message; ?></p></div>
|
8 |
<?php
|
9 |
}
|
10 |
-
if (isset($this->errorMessage)) {
|
11 |
?>
|
12 |
-
<div class="error fade"><p><?php echo $this->errorMessage; ?></p></div>
|
13 |
<?php
|
14 |
}
|
15 |
-
?>
|
16 |
-
|
17 |
<div id="poststuff">
|
18 |
<div id="post-body" class="metabox-holder columns-2">
|
19 |
<!-- Content -->
|
20 |
<div id="post-body-content">
|
21 |
-
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
22 |
<form action="edit.php?post_type=<?php echo $this->plugin->posttype; ?>&page=<?php echo $this->plugin->name; ?>" method="post">
|
23 |
<div class="postbox">
|
24 |
-
<h3 class="hndle"><?php _e('Where do you want ads to display?', $this->plugin->name); ?></h3>
|
25 |
-
|
26 |
-
<div class="inside">
|
27 |
<p>
|
28 |
<?php
|
29 |
-
$postTypes = get_post_types(array(
|
30 |
'public' => true,
|
31 |
), 'objects');
|
32 |
-
if ($postTypes) {
|
33 |
-
foreach ($postTypes as $postType) {
|
34 |
// Skip attachments
|
35 |
-
if ($postType->name == 'attachment') {
|
36 |
continue;
|
37 |
}
|
38 |
?>
|
39 |
<label for="<?php echo $postType->name; ?>"><?php echo $postType->labels->name; ?></label>
|
40 |
-
<input type="checkbox" name="<?php echo $this->plugin->name; ?>[<?php echo $postType->name; ?>]" value="1" id="<?php echo $postType->name; ?>" <?php echo (isset($this->settings[$postType->name]) ? ' checked' : ''); ?>/>
|
41 |
<?php
|
42 |
}
|
43 |
}
|
44 |
?>
|
45 |
-
</p>
|
46 |
<p>
|
47 |
-
<input name="submit" type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Settings', $this->plugin->name); ?>" />
|
48 |
</p>
|
49 |
</div>
|
50 |
</div>
|
51 |
<!-- /postbox -->
|
52 |
-
|
53 |
<div class="postbox">
|
54 |
-
<h3 class="hndle"><?php _e('Display Styling', $this->plugin->name); ?></h3>
|
55 |
-
|
56 |
<div class="inside">
|
57 |
<p>
|
58 |
-
<label for="css"><?php _e('Exclude CSS', $this->plugin->name) ;?></label>
|
59 |
-
<input type="checkbox" name="<?php echo $this->plugin->name; ?>[css]" value="1" id="css" <?php echo (isset($this->settings['css']) ? ' checked' : ''); ?>/>
|
60 |
</p>
|
61 |
<p class="description">
|
62 |
-
<?php _e('By default, Post Ads are wrapped in a container that has some CSS to aid layout. Developers may wish to use their own CSS, and should check this Exclude CSS option.', $this->plugin->name); ?>
|
63 |
</p>
|
64 |
-
|
65 |
<p>
|
66 |
-
<input name="submit" type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Settings', $this->plugin->name); ?>" />
|
67 |
</p>
|
68 |
</div>
|
69 |
</div>
|
70 |
<!-- /postbox -->
|
|
|
71 |
</form>
|
72 |
-
|
73 |
-
<div id="wpbeginner" class="postbox">
|
74 |
-
<h3 class="hndle"><?php _e('Latest from WPBeginner', $this->plugin->name); ?></h3>
|
75 |
-
|
76 |
-
<div class="inside">
|
77 |
-
<?php
|
78 |
-
$this->dashboard->outputDashboardWidget();
|
79 |
-
?>
|
80 |
-
</div>
|
81 |
-
</div>
|
82 |
<!-- /postbox -->
|
83 |
</div>
|
84 |
<!-- /normal-sortables -->
|
85 |
</div>
|
86 |
<!-- /post-body-content -->
|
87 |
-
|
88 |
<!-- Sidebar -->
|
89 |
<div id="postbox-container-1" class="postbox-container">
|
90 |
-
<?php require_once($this->plugin->folder.'/
|
91 |
</div>
|
92 |
<!-- /postbox-container -->
|
93 |
</div>
|
94 |
-
</div>
|
95 |
</div>
|
1 |
<div class="wrap">
|
2 |
+
<h2><?php echo $this->plugin->displayName; ?> » <?php _e( 'Settings', $this->plugin->name ); ?></h2>
|
3 |
+
|
4 |
+
<?php
|
5 |
+
if ( isset( $this->message ) ) {
|
6 |
?>
|
7 |
+
<div class="updated fade"><p><?php echo $this->message; ?></p></div>
|
8 |
<?php
|
9 |
}
|
10 |
+
if ( isset( $this->errorMessage ) ) {
|
11 |
?>
|
12 |
+
<div class="error fade"><p><?php echo $this->errorMessage; ?></p></div>
|
13 |
<?php
|
14 |
}
|
15 |
+
?>
|
16 |
+
|
17 |
<div id="poststuff">
|
18 |
<div id="post-body" class="metabox-holder columns-2">
|
19 |
<!-- Content -->
|
20 |
<div id="post-body-content">
|
21 |
+
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
22 |
<form action="edit.php?post_type=<?php echo $this->plugin->posttype; ?>&page=<?php echo $this->plugin->name; ?>" method="post">
|
23 |
<div class="postbox">
|
24 |
+
<h3 class="hndle"><?php _e( 'Where do you want ads to display?', $this->plugin->name ); ?></h3>
|
25 |
+
|
26 |
+
<div class="inside">
|
27 |
<p>
|
28 |
<?php
|
29 |
+
$postTypes = get_post_types( array(
|
30 |
'public' => true,
|
31 |
), 'objects');
|
32 |
+
if ( $postTypes ) {
|
33 |
+
foreach ( $postTypes as $postType ) {
|
34 |
// Skip attachments
|
35 |
+
if ( $postType->name == 'attachment' ) {
|
36 |
continue;
|
37 |
}
|
38 |
?>
|
39 |
<label for="<?php echo $postType->name; ?>"><?php echo $postType->labels->name; ?></label>
|
40 |
+
<input type="checkbox" name="<?php echo $this->plugin->name; ?>[<?php echo $postType->name; ?>]" value="1" id="<?php echo $postType->name; ?>" <?php echo ( isset( $this->settings[$postType->name] ) ? ' checked' : '' ); ?>/>
|
41 |
<?php
|
42 |
}
|
43 |
}
|
44 |
?>
|
45 |
+
</p>
|
46 |
<p>
|
47 |
+
<input name="submit" type="submit" name="Submit" class="button button-primary" value="<?php _e( 'Save Settings', $this->plugin->name ); ?>" />
|
48 |
</p>
|
49 |
</div>
|
50 |
</div>
|
51 |
<!-- /postbox -->
|
52 |
+
|
53 |
<div class="postbox">
|
54 |
+
<h3 class="hndle"><?php _e( 'Display Styling', $this->plugin->name ); ?></h3>
|
55 |
+
|
56 |
<div class="inside">
|
57 |
<p>
|
58 |
+
<label for="css"><?php _e( 'Exclude CSS', $this->plugin->name ) ;?></label>
|
59 |
+
<input type="checkbox" name="<?php echo $this->plugin->name; ?>[css]" value="1" id="css" <?php echo ( isset( $this->settings['css'] ) ? ' checked' : '' ); ?>/>
|
60 |
</p>
|
61 |
<p class="description">
|
62 |
+
<?php _e( 'By default, Post Ads are wrapped in a container that has some CSS to aid layout. Developers may wish to use their own CSS, and should check this Exclude CSS option.', $this->plugin->name ); ?>
|
63 |
</p>
|
64 |
+
|
65 |
<p>
|
66 |
+
<input name="submit" type="submit" name="Submit" class="button button-primary" value="<?php _e( 'Save Settings', $this->plugin->name ); ?>" />
|
67 |
</p>
|
68 |
</div>
|
69 |
</div>
|
70 |
<!-- /postbox -->
|
71 |
+
<input type="hidden" name="_nonce" value= "<?= wp_create_nonce( $this->plugin->name . '-nonce' ); ?>" />
|
72 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
<!-- /postbox -->
|
74 |
</div>
|
75 |
<!-- /normal-sortables -->
|
76 |
</div>
|
77 |
<!-- /post-body-content -->
|
78 |
+
|
79 |
<!-- Sidebar -->
|
80 |
<div id="postbox-container-1" class="postbox-container">
|
81 |
+
<?php require_once( $this->plugin->folder . '/views/sidebar.php' ); ?>
|
82 |
</div>
|
83 |
<!-- /postbox-container -->
|
84 |
</div>
|
85 |
+
</div>
|
86 |
</div>
|
views/sidebar.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Donations Sidebar
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<!-- Improve Your Site -->
|
7 |
+
<div class="postbox">
|
8 |
+
<h3 class="hndle">
|
9 |
+
<span><?php _e('Improve Your Site', $this->plugin->name); ?></span>
|
10 |
+
</h3>
|
11 |
+
|
12 |
+
<div class="inside">
|
13 |
+
<p>
|
14 |
+
<?php _e( 'Want to take your site to the next level? Check out our daily free WordPress tutorials on ', $this->plugin->name ); ?>
|
15 |
+
<a href="http://www.wpbeginner.com/?utm_source=wpadmin&utm_campaign=freeplugins"><?php _e( 'WPBeginner blog' ); ?></a>.
|
16 |
+
</p>
|
17 |
+
|
18 |
+
<p>
|
19 |
+
<?php _e( 'Some of our popular guides:', $this->plugin->name ); ?>
|
20 |
+
</p>
|
21 |
+
|
22 |
+
<ul>
|
23 |
+
<li><a href="http://www.wpbeginner.com/wordpress-performance-speed/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">
|
24 |
+
<?php _e( 'Speed Up WordPress', $this->plugin->name ); ?>
|
25 |
+
</a></li>
|
26 |
+
<li><a href="http://www.wpbeginner.com/wordpress-security/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">
|
27 |
+
<?php _e( 'Improve WordPress Security', $this->plugin->name ); ?>
|
28 |
+
</a></li>
|
29 |
+
|
30 |
+
<li><a href="http://www.wpbeginner.com/wordpress-seo/?utm_source=wpadmin&utm_campaign=freeplugins" target="_blank">
|
31 |
+
<?php _e( 'Boost Your WordPress SEO', $this->plugin->name ); ?>
|
32 |
+
</a></li>
|
33 |
+
</ul>
|
34 |
+
|
35 |
+
</div>
|
36 |
+
</div>
|
37 |
+
|
38 |
+
<!-- Donate -->
|
39 |
+
<div class="postbox">
|
40 |
+
<h3 class="hndle">
|
41 |
+
<span><?php _e( 'Our WordPress Plugins', $this->plugin->name); ?></span>
|
42 |
+
</h3>
|
43 |
+
<div class="inside">
|
44 |
+
<p>
|
45 |
+
<?php _e( 'Like this plugin? Check out our other WordPress plugins:', $this->plugin->name ); ?>
|
46 |
+
</p>
|
47 |
+
<p>
|
48 |
+
<a href="https://wordpress.org/plugins/wpforms-lite/" target="_blank">
|
49 |
+
<?php _e( 'WPForms', $this->plugin->name ); ?>
|
50 |
+
</a>
|
51 |
+
<?php _e( ' - Drag & Drop WordPress Form Builder', $this->plugin->name ); ?>
|
52 |
+
</p>
|
53 |
+
<p>
|
54 |
+
<a href="https://wordpress.org/plugins/envira-gallery-lite/" target="_blank">
|
55 |
+
<?php _e( 'Envira Gallery', $this->plugin->name ); ?>
|
56 |
+
</a>
|
57 |
+
<?php _e( ' - Responsive WordPress Gallery plugin', $this->plugin->name ); ?>
|
58 |
+
</p>
|
59 |
+
<p>
|
60 |
+
<a href="https://wordpress.org/plugins/google-analytics-for-wordpress/" target="_blank">
|
61 |
+
<?php _e( 'MonsterInsights', $this->plugin->name ); ?>
|
62 |
+
</a>
|
63 |
+
<?php _e( ' - Google Analytics Made Easy for WordPress', $this->plugin->name ); ?>
|
64 |
+
</p>
|
65 |
+
<p>
|
66 |
+
<a href="https://wordpress.org/plugins/soliloquy-lite/" target="_blank">
|
67 |
+
<?php _e( 'Soliloquy', $this->plugin->name ); ?>
|
68 |
+
</a>
|
69 |
+
<?php _e( ' - Responsive WordPress Slider Plugin', $this->plugin->name ); ?>
|
70 |
+
</p>
|
71 |
+
<p>
|
72 |
+
<a href="http://optinmonster.com/" target="_blank">
|
73 |
+
<?php _e( 'OptinMonster', $this->plugin->name ); ?>
|
74 |
+
</a>
|
75 |
+
<?php _e( ' - Best WordPress Lead Generation Plugin', $this->plugin->name ); ?>
|
76 |
+
</p>
|
77 |
+
</div>
|
78 |
+
</div>
|