Post Grid - Version 2.0.61

Version Description

  • 2020-05-29 add - reviews request popup box added.
    • 2020-05-30 add - duplicate/clone post grid and post grid layout added.
    • 2020-05-30 add - addon "Loop ads" added
Download this release

Release Info

Developer pickplugins
Plugin Icon 128x128 Post Grid
Version 2.0.61
Comparing to
See all releases

Code changes from version 2.0.60 to 2.0.61

assets/admin/images/loop-ads.png ADDED
Binary file
includes/classes/class-functions.php CHANGED
@@ -59,6 +59,7 @@ class class_post_grid_functions{
59
60
$args['search'] = array('title' => __('Search & Filter','post-grid'), 'thumb'=> post_grid_plugin_url.'assets/admin/images/search.png', 'item_link' => 'https://github.com/pickplugins/post-grid-search');
61
$args['post-templates'] = array('title' => __('Post/Page Templates','post-grid'), 'thumb'=>post_grid_plugin_url.'assets/admin/images/post-templates.png', 'item_link' => 'https://github.com/pickplugins/post-grid-post-templates');
62
63
64
59
60
$args['search'] = array('title' => __('Search & Filter','post-grid'), 'thumb'=> post_grid_plugin_url.'assets/admin/images/search.png', 'item_link' => 'https://github.com/pickplugins/post-grid-search');
61
$args['post-templates'] = array('title' => __('Post/Page Templates','post-grid'), 'thumb'=>post_grid_plugin_url.'assets/admin/images/post-templates.png', 'item_link' => 'https://github.com/pickplugins/post-grid-post-templates');
62
+ $args['loop-ads'] = array('title' => __('Loop ads','post-grid'), 'thumb'=> post_grid_plugin_url.'assets/admin/images/loop-ads.png', 'item_link' => 'https://github.com/pickplugins/post-grid-loop-ads');
63
64
65
includes/classes/class-settings-tabs-reviews.php ADDED
@@ -0,0 +1,201 @@
1
+ <?php
2
+ if ( ! defined('ABSPATH')) exit; // if direct access
3
+
4
+ if( ! class_exists( 'settings_tabs_reviews' ) ) {
5
+ class settings_tabs_reviews{
6
+
7
+ public $title = 'Hope you enjoy our plugin';
8
+ public $option = 'option_name';
9
+ public $review_link = '';
10
+ public $support_link = '';
11
+ public $documentation_link = '';
12
+ public $tutorials_link = '';
13
+
14
+
15
+ public function __construct($args){
16
+
17
+ $this->title = isset($args['title']) ? $args['title'] : '';
18
+ $this->option = isset($args['option']) ? $args['option'] : '';
19
+ $this->review_link = isset($args['review_link']) ? $args['review_link'] : '';
20
+ $this->support_link = isset($args['support_link']) ? $args['support_link'] : '';
21
+ $this->documentation_link = isset($args['documentation_link']) ? $args['documentation_link'] : '';
22
+ $this->tutorials_link = isset($args['tutorials_link']) ? $args['tutorials_link'] : '';
23
+
24
+
25
+
26
+
27
+ add_action('admin_footer', array($this, 'display_popup'));
28
+ add_action('admin_notices', array( $this, 'review_action_notice' ));
29
+
30
+ }
31
+
32
+ function review_action_notice(){
33
+
34
+ if(!current_user_can('manage_options')) return;
35
+
36
+ $nonce = isset($_GET['_wpnonce']) ? sanitize_text_field($_GET['_wpnonce']) : '';
37
+
38
+ if(wp_verify_nonce( $nonce, $this->option.'_review_notice' ) ) {
39
+ $review_status = isset($_GET['review_status']) ? sanitize_text_field($_GET['review_status']) : '';
40
+ $option = get_option($this->option);
41
+
42
+ $gmt_offset = get_option('gmt_offset');
43
+ $current_date = date('Y-m-d H:i:s', strtotime('+'.$gmt_offset.' hour'));
44
+
45
+ if($review_status =='remind_later'):
46
+
47
+ $option['review_status'] = 'remind_later';
48
+ $option['remind_date'] = date('Y-m-d H:i:s', strtotime('+30 days'));
49
+
50
+ ?>
51
+ <div class="update-nag is-dismissible">We will remind you later.</div>
52
+ <?php
53
+ update_option($this->option, $option);
54
+
55
+ elseif ($review_status =='done'):
56
+
57
+ $option['review_status'] = 'done';
58
+ ?>
59
+ <div class="update-nag notice is-dismissible">Thanks for your time and feedback.</div>
60
+ <?php
61
+
62
+ update_option($this->option, $option);
63
+
64
+ endif;
65
+
66
+
67
+ }
68
+
69
+
70
+
71
+ }
72
+
73
+
74
+ function display_popup(){
75
+
76
+ if(!current_user_can('manage_options')) return;
77
+
78
+ wp_enqueue_style('font-awesome-5');
79
+
80
+ $option = get_option($this->option);
81
+ $review_status = isset($option['review_status']) ? $option['review_status'] : '';
82
+ $remind_date = isset($option['remind_date']) ? $option['remind_date'] : '';
83
+
84
+ $admin_url = get_admin_url();
85
+ //$admin_url = str_replace( '%7E', '~', $_SERVER['REQUEST_URI']);
86
+
87
+
88
+ $gmt_offset = get_option('gmt_offset');
89
+ $today_date = date('Y-m-d H:i:s', strtotime('+'.$gmt_offset.' hour'));
90
+
91
+
92
+ // error_log($review_status);
93
+ // error_log($remind_date);
94
+
95
+
96
+
97
+ if(!empty($review_status)){
98
+ if($review_status == 'done'){ return;}
99
+ if($review_status == 'remind_later' && (strtotime($today_date) < strtotime($remind_date)) ){ return;}
100
+
101
+ }else{
102
+ $option['review_status'] = 'remind_later';
103
+ $option['remind_date'] = date('Y-m-d H:i:s', strtotime('+7 days'));
104
+ update_option($this->option, $option);
105
+
106
+ return;
107
+ }
108
+
109
+ ?>
110
+ <div class="settings-tabs-reviews">
111
+ <div class="actions">
112
+ <span title="To permanently hide please click on Already did." class="hide"><i class="fas fa-times"></i></span>
113
+ </div>
114
+ <div class="title"> <?php echo $this->title; ?></div>
115
+ <div class="content">
116
+ <p class="">We wish your 2 minutes to write your feedback about our plugin. give us <span style="color: #ffae19"><i class="fas fa-star"></i><i class="fas fa-star"></i><i class="fas fa-star"></i><i class="fas fa-star"></i><i class="fas fa-star"></i></span></p>
117
+
118
+ <a target="_blank" href="<?php echo $this->review_link; ?>" class="button"><i class="fab fa-wordpress"></i> Write a review</a>
119
+ <a href="<?php echo wp_nonce_url($admin_url.'?review_status=done', $this->option.'_review_notice', '_wpnonce'); ?>" class="button"><i class="far fa-thumbs-up"></i> Already did</a>
120
+ <a href="<?php echo wp_nonce_url($admin_url.'?review_status=remind_later', $this->option.'_review_notice', '_wpnonce'); ?>" class="button"><i class="far fa-bell"></i> Remind me later</a>
121
+
122
+ <p>Do you have any issue, please contact our support team by creating a support ticket or please watch tutorials and documentation.</p>
123
+ <a target="_blank" href="<?php echo $this->support_link; ?>" class="button"><i class="far fa-question-circle"></i> Create support ticket</a>
124
+ <a target="_blank" href="<?php echo $this->documentation_link; ?>" class="button"><i class="far fa-file-code"></i> Documentation</a>
125
+ <a target="_blank" href="<?php echo $this->tutorials_link; ?>" class="button"><i class="fab fa-youtube"></i> Tutorials</a>
126
+ </div>
127
+
128
+
129
+ </div>
130
+
131
+ <script>
132
+ jQuery(document).ready(function($){
133
+ $(document).on('click', ".settings-tabs-reviews .hide", function() {
134
+ $(this).parent().parent().fadeOut();
135
+ })
136
+ })
137
+ </script>
138
+
139
+ <style type="text/css">
140
+ .settings-tabs-reviews{
141
+ position: fixed;
142
+ right: 15px;
143
+ bottom: 15px;
144
+ width: 500px;
145
+ background: #fff;
146
+ padding: 0px;
147
+ box-shadow: 0 0 6px 3px rgba(183, 183, 183, 0.4);
148
+ z-index: 9999;
149
+ border: 1px solid #3f51b5;
150
+ }
151
+
152
+ .settings-tabs-reviews p{
153
+ font-size: 15px;
154
+ }
155
+
156
+ .settings-tabs-reviews .hide{
157
+ color: #fff;
158
+ padding: 2px 8px;
159
+ background: #e21d1d;
160
+ margin: 7px 4px;
161
+ display: inline-block;
162
+ cursor: pointer;
163
+ }
164
+
165
+ .settings-tabs-reviews .title{
166
+ font-size: 17px;
167
+ border-bottom: 1px solid #ddd;
168
+ padding: 10px;
169
+ background: #3F51B5;
170
+ color: #fff;
171
+ }
172
+
173
+ .settings-tabs-reviews .content{
174
+ padding: 10px;
175
+ }
176
+
177
+ .settings-tabs-reviews .actions{
178
+ position: absolute;
179
+ top: 0;
180
+ right: 0;
181
+ }
182
+
183
+ @media only screen and ( min-width: 0px ) and ( max-width: 767px ){
184
+ .settings-tabs-reviews{
185
+ width: 100%;
186
+ right: 0;
187
+ bottom: 0;
188
+ }
189
+ }
190
+
191
+
192
+ </style>
193
+ <?php
194
+
195
+ }
196
+
197
+ }
198
+
199
+
200
+ }
201
+
includes/duplicate-post.php ADDED
@@ -0,0 +1,138 @@
1
+ <?php
2
+ if ( ! defined('ABSPATH')) exit; // if direct access
3
+
4
+ if(!class_exists('PPduplicatePost')){
5
+ class PPduplicatePost{
6
+
7
+ public $post_types = array();
8
+
9
+ function __construct($args){
10
+
11
+ $this->post_types = isset($args['post_types']) ? $args['post_types'] : array();
12
+
13
+ add_filter( 'post_row_actions', array($this, 'duplicate_post_link'), 10, 2 );
14
+
15
+
16
+ add_action( 'admin_action_duplicate_post_as_draft', array($this, 'duplicate_post_as_draft') );
17
+
18
+
19
+ }
20
+
21
+
22
+ function duplicate_post_link( $actions, $post ) {
23
+
24
+
25
+ if (current_user_can('edit_posts') && in_array($post->post_type, $this->post_types) ) {
26
+ $actions['duplicate'] = '<a href="' . wp_nonce_url('admin.php?action=duplicate_post_as_draft&post=' . $post->ID, basename(__FILE__), 'duplicate_post_nonce' ) . '" title="Duplicate this item" rel="permalink">Duplicate</a>';
27
+ }
28
+ return $actions;
29
+ }
30
+
31
+
32
+
33
+
34
+ function duplicate_post_as_draft(){
35
+
36
+
37
+ //var_dump('Hello');
38
+
39
+ global $wpdb;
40
+ if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
41
+ wp_die('No post to duplicate has been supplied!');
42
+ }
43
+
44
+ /*
45
+ * Nonce verification
46
+ */
47
+ if ( !isset( $_GET['duplicate_post_nonce'] ) || !wp_verify_nonce( $_GET['duplicate_post_nonce'], basename( __FILE__ ) ) )
48
+ return;
49
+
50
+ /*
51
+ * get the original post id
52
+ */
53
+ $post_id = (isset($_GET['post']) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
54
+ /*
55
+ * and all the original post data then
56
+ */
57
+ $post = get_post( $post_id );
58
+
59
+ /*
60
+ * if you don't want current user to be the new post author,
61
+ * then change next couple of lines to this: $new_post_author = $post->post_author;
62
+ */
63
+ $current_user = wp_get_current_user();
64
+ $new_post_author = $current_user->ID;
65
+
66
+ /*
67
+ * if post data exists, create the post duplicate
68
+ */
69
+ if (isset( $post ) && $post != null) {
70
+
71
+ /*
72
+ * new post data array
73
+ */
74
+ $args = array(
75
+ 'comment_status' => $post->comment_status,
76
+ 'ping_status' => $post->ping_status,
77
+ 'post_author' => $new_post_author,
78
+ 'post_content' => $post->post_content,
79
+ 'post_excerpt' => $post->post_excerpt,
80
+ 'post_name' => $post->post_name,
81
+ 'post_parent' => $post->post_parent,
82
+ 'post_password' => $post->post_password,
83
+ 'post_status' => 'draft',
84
+ 'post_title' => $post->post_title.' - Copy of #'.$post_id,
85
+ 'post_type' => $post->post_type,
86
+ 'to_ping' => $post->to_ping,
87
+ 'menu_order' => $post->menu_order
88
+ );
89
+
90
+ /*
91
+ * insert the post by wp_insert_post() function
92
+ */
93
+ $new_post_id = wp_insert_post( $args );
94
+
95
+ /*
96
+ * get all current post terms ad set them to the new post draft
97
+ */
98
+ $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array("category", "post_tag");
99
+ foreach ($taxonomies as $taxonomy) {
100
+ $post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
101
+ wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
102
+ }
103
+
104
+ /*
105
+ * duplicate all post meta just in two SQL queries
106
+ */
107
+ $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
108
+ if (count($post_meta_infos)!=0) {
109
+ $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
110
+ foreach ($post_meta_infos as $meta_info) {
111
+ $meta_key = $meta_info->meta_key;
112
+ if( $meta_key == '_wp_old_slug' ) continue;
113
+ $meta_value = addslashes($meta_info->meta_value);
114
+ $sql_query_sel[]= "SELECT $new_post_id, '$meta_key', '$meta_value'";
115
+ }
116
+ $sql_query.= implode(" UNION ALL ", $sql_query_sel);
117
+ $wpdb->query($sql_query);
118
+ }
119
+
120
+
121
+ /*
122
+ * finally, redirect to the edit post screen for the new draft
123
+ */
124
+ wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_post_id ) );
125
+ exit;
126
+ } else {
127
+ wp_die('Post creation failed, could not find original post: ' . $post_id);
128
+ }
129
+ }
130
+
131
+
132
+ }
133
+ }
134
+
135
+
136
+
137
+
138
+
includes/functions-data-upgrade.php CHANGED
@@ -1261,7 +1261,7 @@ function post_grid_import_xml_layouts(){
1261
array(
1262
'post_title' => $post_title,
1263
'post_content' => '',
1264
- 'post_status' => 'draft',
1265
'post_type' => 'post_grid_layout',
1266
'post_author' => $user_id,
1267
)
1261
array(
1262
'post_title' => $post_title,
1263
'post_content' => '',
1264
+ 'post_status' => 'publish',
1265
'post_type' => 'post_grid_layout',
1266
'post_author' => $user_id,
1267
)
includes/settings-hook.php CHANGED
@@ -108,7 +108,10 @@ if(!function_exists('post_grid_settings_content_help_support')) {
108
109
<p><b>Post Gird</b> provide some ready layouts to get started, please follow the steps bellow to import default layouts.</p>
110
111
<a class="button post-grid-import-layouts" href="<?php echo esc_url_raw($layouts_free_url_json); ?>"><?php echo __('Import automatically', 'post-grid'); ?></a>
112
113
114
<p>Import manually</p>
@@ -120,8 +123,6 @@ if(!function_exists('post_grid_settings_content_help_support')) {
120
<li>Step - 4: Go to <a href="<?php echo admin_url(); ?>edit.php?post_type=post_grid_layout">Post Grid layouts</a> page to see imported layouts.</li>
121
</ul>
122
123
- <p><?php echo __('Download free layouts', 'post-grid'); ?></p>
124
- <a class="button" href="<?php echo esc_url_raw($layouts_free_url); ?>"><?php echo __('Download XML', 'post-grid'); ?></a>
125
126
127
<?php
108
109
<p><b>Post Gird</b> provide some ready layouts to get started, please follow the steps bellow to import default layouts.</p>
110
111
+ <p><?php echo __('Import free layouts', 'post-grid'); ?></p>
112
+
113
<a class="button post-grid-import-layouts" href="<?php echo esc_url_raw($layouts_free_url_json); ?>"><?php echo __('Import automatically', 'post-grid'); ?></a>
114
+ <a class="button" href="<?php echo esc_url_raw($layouts_free_url); ?>"><?php echo __('Download XML', 'post-grid'); ?></a>
115
116
117
<p>Import manually</p>
123
<li>Step - 4: Go to <a href="<?php echo admin_url(); ?>edit.php?post_type=post_grid_layout">Post Grid layouts</a> page to see imported layouts.</li>
124
</ul>
125
126
127
128
<?php
post-grid.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Post Grid by PickPlugins
4
Plugin URI: https://www.pickplugins.com/item/post-grid-create-awesome-grid-from-any-post-type-for-wordpress/
5
Description: Awesome post grid for query post from any post type and display on grid.
6
- Version: 2.0.60
7
Author: PickPlugins
8
Author URI: https://www.pickplugins.com/
9
License: GPLv2 or later
@@ -21,7 +21,7 @@ if( !class_exists( 'PostGrid' )){
21
define('post_grid_plugin_dir', plugin_dir_path(__FILE__));
22
define('post_grid_plugin_basename', plugin_basename(__FILE__));
23
define('post_grid_plugin_name', 'Post Grid');
24
- define('post_grid_version', '2.0.60');
25
26
27
@@ -31,6 +31,9 @@ if( !class_exists( 'PostGrid' )){
31
include('includes/classes/class-shortcodes.php');
32
include('includes/classes/class-settings.php');
33
include('includes/classes/class-settings-tabs.php');
34
include('includes/classes/class-admin-notices.php');
35
36
include('includes/metabox-post-grid-layout-hook.php');
@@ -54,6 +57,7 @@ if( !class_exists( 'PostGrid' )){
54
include('includes/functions-post-grid.php');
55
include('includes/functions.php');
56
include('includes/shortcodes/shortcode-current_user_id.php');
57
58
59
add_action('wp_enqueue_scripts', array($this, '_scripts_front'));
@@ -65,6 +69,25 @@ if( !class_exists( 'PostGrid' )){
65
register_activation_hook(__FILE__, array($this, '_activation'));
66
register_deactivation_hook(__FILE__, array($this, '_deactivation'));
67
68
69
}
70
3
Plugin Name: Post Grid by PickPlugins
4
Plugin URI: https://www.pickplugins.com/item/post-grid-create-awesome-grid-from-any-post-type-for-wordpress/
5
Description: Awesome post grid for query post from any post type and display on grid.
6
+ Version: 2.0.61
7
Author: PickPlugins
8
Author URI: https://www.pickplugins.com/
9
License: GPLv2 or later
21
define('post_grid_plugin_dir', plugin_dir_path(__FILE__));
22
define('post_grid_plugin_basename', plugin_basename(__FILE__));
23
define('post_grid_plugin_name', 'Post Grid');
24
+ define('post_grid_version', '2.0.61');
25
26
27
31
include('includes/classes/class-shortcodes.php');
32
include('includes/classes/class-settings.php');
33
include('includes/classes/class-settings-tabs.php');
34
+ include('includes/classes/class-settings-tabs-reviews.php');
35
+
36
+
37
include('includes/classes/class-admin-notices.php');
38
39
include('includes/metabox-post-grid-layout-hook.php');
57
include('includes/functions-post-grid.php');
58
include('includes/functions.php');
59
include('includes/shortcodes/shortcode-current_user_id.php');
60
+ include('includes/duplicate-post.php');
61
62
63
add_action('wp_enqueue_scripts', array($this, '_scripts_front'));
69
register_activation_hook(__FILE__, array($this, '_activation'));
70
register_deactivation_hook(__FILE__, array($this, '_deactivation'));
71
72
+ $args = array(
73
+ 'title' => 'Hope you enjoy <b>post grid</b> plugin ',
74
+ 'option' => 'post_grid_info',
75
+ 'review_link' => 'https://wordpress.org/support/plugin/post-grid/reviews/#new-post',
76
+ 'support_link' => 'https://www.pickplugins.com/forum/',
77
+ 'documentation_link' => 'https://www.pickplugins.com/documentation/post-grid/',
78
+ 'tutorials_link' => 'https://www.youtube.com/playlist?list=PL0QP7T2SN94Yut5Y0MSVg1wqmqWz0UYpt',
79
+ );
80
+
81
+ new settings_tabs_reviews($args);
82
+
83
+ //echo $settings_tabs_reviews;
84
+
85
+
86
+ $args = array(
87
+ 'post_types' => array('post_grid', 'post_grid_layout'),
88
+ );
89
+
90
+ new PPduplicatePost($args);
91
92
}
93
readme.txt CHANGED
@@ -4,7 +4,7 @@
4
Tags: post grid, grid, custom post grid, post type grid, grid display, category filter, custom post, filter, filtering, grid, layout, list, masonry, post, post filter, post layout, taxonomy, taxonomy filter,
5
Requires at least: 3.8
6
Tested up to: 5.4
7
- Stable tag: 2.0.60
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -216,6 +216,11 @@ then paste this shortcode anywhere in your page to display grid<br />
216
217
== Changelog ==
218
219
= 2.0.60 =
220
* 2020-05-24 add - addon "Search & Filter" added
221
* 2020-05-24 add - addon "Post/Page Templates" added
4
Tags: post grid, grid, custom post grid, post type grid, grid display, category filter, custom post, filter, filtering, grid, layout, list, masonry, post, post filter, post layout, taxonomy, taxonomy filter,
5
Requires at least: 3.8
6
Tested up to: 5.4
7
+ Stable tag: 2.0.61
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
216
217
== Changelog ==
218
219
+ = 2.0.61 =
220
+ * 2020-05-29 add - reviews request popup box added.
221
+ * 2020-05-30 add - duplicate/clone post grid and post grid layout added.
222
+ * 2020-05-30 add - addon "Loop ads" added
223
+
224
= 2.0.60 =
225
* 2020-05-24 add - addon "Search & Filter" added
226
* 2020-05-24 add - addon "Post/Page Templates" added