PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.8
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.8
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / admin / help-page / class-sps-recommended.php

class-sps-recommended.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.8, at admin/help-page/class-sps-recommended.php

465 lines 14.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The help page for the Smart Post Show Free
4 *
5 * @package Smart Post Show Free
6 * @subpackage post-carousel/admin
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 } // if direct access.
12
13 /**
14 * The help class for the Smart Post Show Free
15 */
16 class SPS_Recommended {
17
18 /**
19 * Single instance of the class
20 *
21 * @var null
22 */
23 protected static $instance = null;
24
25 /**
26 * Plugins Path variable.
27 *
28 * @var array
29 */
30 protected static $plugins = array(
31 'woo-product-slider' => 'main.php',
32 'gallery-slider-for-woocommerce' => 'woo-gallery-slider.php',
33 'post-carousel' => 'main.php',
34 'easy-accordion-free' => 'plugin-main.php',
35 'logo-carousel-free' => 'main.php',
36 'location-weather' => 'main.php',
37 'woo-quickview' => 'woo-quick-view.php',
38 'wp-expand-tabs-free' => 'plugin-main.php',
39
40 );
41
42 /**
43 * Welcome pages
44 *
45 * @var array
46 */
47 public $pages = array(
48 'pcp_help',
49 );
50
51
52 /**
53 * Not show this plugin list.
54 *
55 * @var array
56 */
57 protected static $not_show_plugin_list = array( 'aitasi-coming-soon', 'latest-posts', 'widget-post-slider', 'post-carousel', 'easy-lightbox-wp' );
58
59 /**
60 * Easy_Accordion_Free_Help construct function.
61 */
62 public function __construct() {
63 add_action( 'admin_menu', array( $this, 'help_admin_menu' ), 20 );
64
65 $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';// @codingStandardsIgnoreLine
66 if ( 'pcp_help' !== $page ) {
67 return;
68 }
69 add_action( 'admin_print_scripts', array( $this, 'disable_admin_notices' ) );
70 add_action( 'spf_enqueue', array( $this, 'help_page_enqueue_scripts' ) );
71 }
72
73 /**
74 * Main help page Instance
75 *
76 * @static
77 * @return self Main instance
78 */
79 public static function instance() {
80 if ( is_null( self::$instance ) ) {
81 self::$instance = new self();
82 }
83
84 return self::$instance;
85 }
86
87 /**
88 * Help_page_enqueue_scripts function.
89 *
90 * @return void
91 */
92 public function help_page_enqueue_scripts() {
93 wp_enqueue_style( 'sp-post-carousel-help', SP_PC_URL . 'admin/help-page/css/help-page.min.css', array(), SP_PC_VERSION );
94 wp_enqueue_style( 'sp-post-carousel-help-fontello', SP_PC_URL . 'admin/help-page/css/fontello.min.css', array(), SP_PC_VERSION );
95
96 wp_enqueue_script( 'sp-post-carousel-help', SP_PC_URL . 'admin/help-page/js/help-page.min.js', array(), SP_PC_VERSION, true );
97 }
98
99 /**
100 * Add admin menu.
101 *
102 * @return void
103 */
104 public function help_admin_menu() {
105 // add_submenu_page(
106 // 'edit.php?post_type=sp_post_carousel',
107 // __( 'Post Carousel', 'post-carousel' ),
108 // 'Blocks <span class="eap-menu-new-indicator" style="color: #f18200;font-size: 9px; padding-left: 3px;"> NEW!</span>',
109 // 'manage_options',
110 // 'edit.php?post_type=sp_post_carousel&page=pcp_help#blocks',
111 // '',
112 // 0
113 // );
114 // add_submenu_page(
115 // 'edit.php?post_type=sp_post_carousel',
116 // __( 'Post Carousel', 'post-carousel' ),
117 // __( 'Saved Templates', 'post-carousel' ),
118 // 'manage_options',
119 // 'edit.php?post_type=sp_post_carousel&page=pcp_help#savedTemplate',
120 // '',
121 // 1
122 // );
123 add_submenu_page(
124 'edit.php?post_type=sp_post_carousel',
125 __( 'Post Carousel', 'post-carousel' ),
126 __( 'Settings', 'post-carousel' ),
127 'manage_options',
128 'edit.php?post_type=sp_post_carousel&page=pcp_help#settings',
129 '',
130 20
131 );
132 add_submenu_page(
133 'edit.php?post_type=sp_post_carousel',
134 __( 'Smart Post Show Help', 'post-carousel' ),
135 __( 'Quick Start', 'post-carousel' ),
136 'manage_options',
137 'pcp_help',
138 array(
139 $this,
140 'help_page_callback',
141 ),
142 0
143 );
144
145 add_submenu_page(
146 'edit.php?post_type=sp_post_carousel',
147 __( 'Post Carousel', 'post-carousel' ),
148 __( 'Lite vs Pro', 'post-carousel' ),
149 'manage_options',
150 'edit.php?post_type=sp_post_carousel&page=pcp_help#lite-vs-pro',
151 '',
152 10
153 );
154
155 add_submenu_page(
156 'edit.php?post_type=sp_post_carousel',
157 __( 'Upgrade to Pro', 'post-carousel' ),
158 '<a class="sp-smart-post-upgrade-btn-wrapper" href="https://wpsmartpost.com/pricing/?ref=1" target="_blank">
159 <span class="sp-smart-post-upgrade-btn">
160 <span class="sp-go-pro-icon"></span> Upgrade to Pro
161 </span>
162 </a>',
163 'manage_options',
164 'pcp_help',
165 '__return_null',
166 80
167 );
168 }
169
170 /**
171 * Spspc_ajax_help_page function.
172 *
173 * @return void
174 */
175 public function spspc_plugins_info_api_help_page() {
176 $plugins_arr = get_transient( 'spspc_plugins' );
177 if ( false === $plugins_arr ) {
178 $args = array(
179 'author' => 'shapedplugin',
180 'per_page' => '120',
181 'page' => '1',
182 'fields' => array(
183 'slug',
184 'name',
185 'version',
186 'downloaded',
187 'active_installs',
188 'last_updated',
189 'rating',
190 'num_ratings',
191 'short_description',
192 'author',
193 'icons',
194 ),
195 );
196
197 if ( ! function_exists( 'plugins_api' ) ) {
198 require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
199 }
200
201 $plugin_info = plugins_api( 'query_plugins', $args );
202
203 if ( ! is_wp_error( $plugin_info ) ) {
204
205 $plugins_arr = array();
206 if ( isset( $plugin_info->plugins ) && ( count( $plugin_info->plugins ) > 0 ) ) {
207 foreach ( $plugin_info->plugins as $pl ) {
208 if ( ! in_array( $pl['slug'], self::$not_show_plugin_list, true ) ) {
209 $plugins_arr[] = array(
210 'slug' => $pl['slug'],
211 'name' => $pl['name'],
212 'version' => $pl['version'],
213 'downloaded' => $pl['downloaded'],
214 'active_installs' => $pl['active_installs'],
215 'last_updated' => strtotime( $pl['last_updated'] ),
216 'rating' => $pl['rating'],
217 'num_ratings' => $pl['num_ratings'],
218 'short_description' => $pl['short_description'],
219 'icons' => $pl['icons']['2x'],
220 );
221 }
222 }
223 }
224
225 set_transient( 'spspc_plugins', $plugins_arr, 24 * HOUR_IN_SECONDS );
226 }
227 }
228
229 if ( is_array( $plugins_arr ) && ( count( $plugins_arr ) > 0 ) ) {
230 $active_installs = array_column( $plugins_arr, 'active_installs' );
231 array_multisort( $active_installs, SORT_DESC, $plugins_arr );
232
233 foreach ( $plugins_arr as $plugin ) {
234 $plugin_slug = $plugin['slug'];
235 $plugin_icon = $plugin['icons'];
236 if ( isset( self::$plugins[ $plugin_slug ] ) ) {
237 $plugin_file = self::$plugins[ $plugin_slug ];
238 } else {
239 $plugin_file = $plugin_slug . '.php';
240 }
241 // Skip the plugin if it is not installed.
242 if ( 'post-carousel' === $plugin_slug ) {
243 continue;
244 }
245
246 $details_link = network_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] . '&amp;TB_iframe=true&amp;width=745&amp;height=550' );
247 ?>
248 <div class="plugin-card <?php echo esc_attr( $plugin_slug ); ?>" id="<?php echo esc_attr( $plugin_slug ); ?>">
249 <div class="plugin-card-top">
250 <div class="name column-name">
251 <h3>
252 <a class="thickbox" title="<?php echo esc_attr( $plugin['name'] ); ?>" href="<?php echo esc_url( $details_link ); ?>">
253 <?php echo esc_html( $plugin['name'] ); ?>
254 <img src="<?php echo esc_url( $plugin_icon ); ?>" class="plugin-icon"/>
255 </a>
256 </h3>
257 </div>
258 <div class="action-links">
259 <ul class="plugin-action-buttons">
260 <li>
261 <?php
262 if ( $this->is_plugin_installed( $plugin_slug, $plugin_file ) ) {
263 if ( $this->is_plugin_active( $plugin_slug, $plugin_file ) ) {
264 ?>
265 <button type="button" class="button button-disabled" disabled="disabled">Active</button>
266 <?php
267 } else {
268 ?>
269 <a href="<?php echo esc_url( $this->activate_plugin_link( $plugin_slug, $plugin_file ) ); ?>" class="button button-primary activate-now">
270 <?php esc_html_e( 'Activate', 'post-carousel' ); ?>
271 </a>
272 <?php
273 }
274 } else {
275 ?>
276 <a href="<?php echo esc_url( $this->install_plugin_link( $plugin_slug ) ); ?>" class="button install-now">
277 <?php esc_html_e( 'Install Now', 'post-carousel' ); ?>
278 </a>
279 <?php } ?>
280 </li>
281 <li>
282 <a href="<?php echo esc_url( $details_link ); ?>" class="thickbox open-plugin-details-modal" aria-label="<?php echo esc_attr( 'More information about ' . $plugin['name'] ); ?>" title="<?php echo esc_attr( $plugin['name'] ); ?>">
283 <?php esc_html_e( 'More Details', 'post-carousel' ); ?>
284 </a>
285 </li>
286 </ul>
287 </div>
288 <div class="desc column-description">
289 <p><?php echo esc_html( isset( $plugin['short_description'] ) ? $plugin['short_description'] : '' ); ?></p>
290 <p class="authors"> <cite>By <a href="https://shapedplugin.com/">ShapedPlugin LLC</a></cite></p>
291 </div>
292 </div>
293 <?php
294 echo '<div class="plugin-card-bottom">';
295
296 if ( isset( $plugin['rating'], $plugin['num_ratings'] ) ) {
297 ?>
298 <div class="vers column-rating">
299 <?php
300 wp_star_rating(
301 array(
302 'rating' => $plugin['rating'],
303 'type' => 'percent',
304 'number' => $plugin['num_ratings'],
305 )
306 );
307 ?>
308 <span class="num-ratings">(<?php echo esc_html( number_format_i18n( $plugin['num_ratings'] ) ); ?>)</span>
309 </div>
310 <?php
311 }
312 if ( isset( $plugin['version'] ) ) {
313 ?>
314 <div class="column-updated">
315 <strong><?php esc_html_e( 'Version:', 'post-carousel' ); ?></strong>
316 <span><?php echo esc_html( $plugin['version'] ); ?></span>
317 </div>
318 <?php
319 }
320
321 if ( isset( $plugin['active_installs'] ) ) {
322 ?>
323 <div class="column-downloaded">
324 <?php echo esc_html( number_format_i18n( $plugin['active_installs'] ) ) . esc_html__( '+ Active Installations', 'post-carousel' ); ?>
325 </div>
326 <?php
327 }
328
329 if ( isset( $plugin['last_updated'] ) ) {
330 ?>
331 <div class="column-compatibility">
332 <strong><?php esc_html_e( 'Last Updated:', 'post-carousel' ); ?></strong>
333 <span><?php echo esc_html( human_time_diff( $plugin['last_updated'] ) ) . ' ' . esc_html__( 'ago', 'post-carousel' ); ?></span>
334 </div>
335 <?php
336 }
337
338 echo '</div>';
339 ?>
340 </div>
341 <?php
342 }
343 }
344 }
345
346 /**
347 * Check plugins installed function.
348 *
349 * @param string $plugin_slug Plugin slug.
350 * @param string $plugin_file Plugin file.
351 * @return boolean
352 */
353 public function is_plugin_installed( $plugin_slug, $plugin_file ) {
354 return file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug . '/' . $plugin_file );
355 }
356
357 /**
358 * Check active plugin function
359 *
360 * @param string $plugin_slug Plugin slug.
361 * @param string $plugin_file Plugin file.
362 * @return boolean
363 */
364 public function is_plugin_active( $plugin_slug, $plugin_file ) {
365 return is_plugin_active( $plugin_slug . '/' . $plugin_file );
366 }
367
368 /**
369 * Install plugin link.
370 *
371 * @param string $plugin_slug Plugin slug.
372 * @return string
373 */
374 public function install_plugin_link( $plugin_slug ) {
375 return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug ), 'install-plugin_' . $plugin_slug );
376 }
377
378 /**
379 * Active Plugin Link function
380 *
381 * @param string $plugin_slug Plugin slug.
382 * @param string $plugin_file Plugin file.
383 * @return string
384 */
385 public function activate_plugin_link( $plugin_slug, $plugin_file ) {
386 return wp_nonce_url( admin_url( 'edit.php?post_type=sp_post_carousel&page=pcp_help&action=activate&plugin=' . $plugin_slug . '/' . $plugin_file . '#about-us' ), 'activate-plugin_' . $plugin_slug . '/' . $plugin_file );
387 }
388
389 /**
390 * Making page as clean as possible
391 */
392 public function disable_admin_notices() {
393
394 global $wp_filter;
395
396 if ( isset( $_GET['post_type'] ) && isset( $_GET['page'] ) && 'sp_post_carousel' === wp_unslash( $_GET['post_type'] ) && in_array( wp_unslash( $_GET['page'] ), $this->pages ) ) { // @codingStandardsIgnoreLine
397
398 if ( isset( $wp_filter['user_admin_notices'] ) ) {
399 unset( $wp_filter['user_admin_notices'] );
400 }
401 if ( isset( $wp_filter['admin_notices'] ) ) {
402 unset( $wp_filter['admin_notices'] );
403 }
404 if ( isset( $wp_filter['all_admin_notices'] ) ) {
405 unset( $wp_filter['all_admin_notices'] );
406 }
407 }
408 }
409
410 /**
411 * The Smart Post Show Help Callback.
412 *
413 * @return void
414 */
415 public function help_page_callback() {
416 add_thickbox();
417
418 $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : '';
419 $plugin = isset( $_GET['plugin'] ) ? sanitize_text_field( wp_unslash( $_GET['plugin'] ) ) : '';
420 $_wpnonce = isset( $_GET['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ) : '';
421
422 if ( isset( $action, $plugin ) && ( 'activate' === $action ) && wp_verify_nonce( $_wpnonce, 'activate-plugin_' . $plugin ) && current_user_can( 'activate_plugins' ) ) {
423 activate_plugin( $plugin, '', false, true );
424 }
425
426 if ( isset( $action, $plugin ) && ( 'deactivate' === $action ) && wp_verify_nonce( $_wpnonce, 'deactivate-plugin_' . $plugin ) && current_user_can( 'deactivate_plugins' ) ) {
427 deactivate_plugins( $plugin, '', false );
428 }
429
430 ?>
431 <div class="sp-smart-post__help">
432 <div id="sp-smart-post-blocks-settings-page" class="sp-smart-post-blocks-settings-page"></div>
433
434 <!-- Recommended Page -->
435 <section id="recommended-tab" class="spspc-recommended-page">
436 <div class="spspc-container">
437 <h2 class="spspc-section-title">Supercharge Your Website with Our Free Plugins Trusted by 360,050+ Users</h2>
438 <div class="spspc-wp-list-table plugin-install-php">
439 <div class="spspc-recommended-plugins" id="the-list">
440 <?php
441 $this->spspc_plugins_info_api_help_page();
442 ?>
443 </div>
444 </div>
445 </div>
446 </section>
447
448 <!-- Footer Section -->
449 <!-- <section class="spspc-footer">
450 <div class="spspc-footer-top">
451 <p><span>Made With <i class="spspc-icon-heart"></i> </span> By the <a target="_blank" href="https://shapedplugin.com/">ShapedPlugin LLC</a> Team</p>
452 <p>Get connected with</p>
453 <ul>
454 <li><a target="_blank" href="https://www.facebook.com/ShapedPlugin/"><i class="spspc-icon-fb"></i></a></li>
455 <li><a target="_blank" href="https://twitter.com/intent/follow?screen_name=ShapedPlugin"><i class="spspc-icon-x"></i></a></li>
456 <li><a target="_blank" href="https://profiles.wordpress.org/shapedplugin/#content-plugins"><i class="spspc-icon-wp-icon"></i></a></li>
457 <li><a target="_blank" href="https://youtube.com/@ShapedPlugin?sub_confirmation=1"><i class="spspc-icon-youtube-play"></i></a></li>
458 </ul>
459 </div>
460 </section> -->
461 </div>
462 <?php
463 }
464 }
465