initial commit
This commit is contained in:
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin Class
|
||||
*
|
||||
* Handles admin side functionality of plugin
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Wtpsw_Admin {
|
||||
|
||||
function __construct() {
|
||||
|
||||
// Action to register admin menu
|
||||
add_action( 'admin_menu', array($this, 'wtpsw_register_menu') );
|
||||
|
||||
// Action to register plugin settings
|
||||
add_action ( 'admin_init', array($this,'wtpsw_admin_processes') );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to register admin menus
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_register_menu() {
|
||||
|
||||
// Register Setting Page
|
||||
add_menu_page ( __('Trending Post', 'wtpsw'), __('Trending Post', 'wtpsw'), 'manage_options', 'wtpsw-settings', array($this, 'wtpsw_settings_page'), 'dashicons-star-filled' );
|
||||
|
||||
// Register How It Work Page
|
||||
add_submenu_page( 'wtpsw-settings', __('Getting Started - WP Trending Post Slider and Widget', 'wtpsw'), __('Getting Started', 'wtpsw'), 'edit_posts', 'wtpsw-help', array($this, 'wtpsw_designs_page') );
|
||||
|
||||
// Register plugin premium page
|
||||
add_submenu_page( 'wtpsw-settings', __('Upgrade To Premium - Trending/Popular Post Slider and Widget', 'wtpsw'), '<span style="color:#ff2700">'.__('Upgrade To Premium', 'wtpsw').'</span>', 'manage_options', 'wtpsw-premium', array($this, 'wtpsw_premium_page') );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to handle the setting page html
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_settings_page() {
|
||||
include_once( WTPSW_DIR . '/includes/admin/form/wtpsw-settings.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* How It Work Page
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_designs_page() {
|
||||
include_once( WTPSW_DIR . '/includes/admin/wtpsw-how-it-works.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade to PRO Vs Free
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_premium_page() {
|
||||
include_once( WTPSW_DIR . '/includes/admin/form/premium.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function register setings
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_admin_processes() {
|
||||
|
||||
// If plugin notice is dismissed
|
||||
if( isset($_GET['message']) && $_GET['message'] == 'wtpsw-plugin-notice' ) {
|
||||
set_transient( 'wtpsw_install_notice', true, 604800 );
|
||||
}
|
||||
|
||||
register_setting( 'wtpsw_plugin_options', 'wtpsw_options', array($this, 'wtpsw_validate_options') );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Settings Options
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_validate_options( $input ){
|
||||
|
||||
$input['post_types'] = isset($input['post_types']) ? $input['post_types'] : array();
|
||||
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
|
||||
$wtpsw_Admin = new Wtpsw_Admin();
|
@ -0,0 +1,236 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Premium Offer Page
|
||||
*
|
||||
* @package Trending/Popular Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
?>
|
||||
<div class="wrap">
|
||||
|
||||
<h2><?php _e( 'WP Trending Post Slider and Widget', 'wtpsw' ); ?></h2><br />
|
||||
<style>
|
||||
.wpos-plugin-pricing-table thead th h2{font-weight: 400; font-size: 2.4em; line-height:normal; margin:0px; color: #2ECC71;}
|
||||
.wpos-plugin-pricing-table thead th h2 + p{font-size: 1.25em; line-height: 1.4; color: #999; margin:5px 0 5px 0;}
|
||||
|
||||
table.wpos-plugin-pricing-table{width:100%; text-align: left; border-spacing: 0; border-collapse: collapse; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;}
|
||||
|
||||
.wpos-plugin-pricing-table th, .wpos-plugin-pricing-table td{font-size:14px; line-height:normal; color:#444; vertical-align:middle; padding:12px;}
|
||||
|
||||
.wpos-plugin-pricing-table colgroup:nth-child(1) { width: 31%; border: 0 none; }
|
||||
.wpos-plugin-pricing-table colgroup:nth-child(2) { width: 22%; border: 1px solid #ccc; }
|
||||
.wpos-plugin-pricing-table colgroup:nth-child(3) { width: 25%; border: 10px solid #2ECC71; }
|
||||
|
||||
/* Tablehead */
|
||||
.wpos-plugin-pricing-table thead th {background-color: #fff; background:linear-gradient(to bottom, #ffffff 0%, #ffffff 100%); text-align: center; position: relative; border-bottom: 1px solid #ccc; padding: 1em 0 1em; font-weight:400; color:#999;}
|
||||
.wpos-plugin-pricing-table thead th:nth-child(1) {background: transparent;}
|
||||
.wpos-plugin-pricing-table thead th:nth-child(3) p{color:#000;}
|
||||
.wpos-plugin-pricing-table thead th p.promo {font-size: 14px; color: #fff; position: absolute; bottom:0; left: -17px; z-index: 1000; width: 100%; margin: 0; padding: .625em 17px .75em; background-color: #ca4a1f; box-shadow: 0 2px 4px rgba(0,0,0,.25); border-bottom: 1px solid #ca4a1f;}
|
||||
.wpos-plugin-pricing-table thead th p.promo:before {content: ""; position: absolute; display: block; width: 0px; height: 0px; border-style: solid; border-width: 0 7px 7px 0; border-color: transparent #900 transparent transparent; bottom: -7px; left: 0;}
|
||||
.wpos-plugin-pricing-table thead th p.promo:after {content: ""; position: absolute; display: block; width: 0px; height: 0px; border-style: solid; border-width: 7px 7px 0 0; border-color: #900 transparent transparent transparent; bottom: -7px; right: 0;}
|
||||
|
||||
/* Tablebody */
|
||||
.wpos-plugin-pricing-table tbody th{background: #fff; border-left: 1px solid #ccc; font-weight: 600;}
|
||||
.wpos-plugin-pricing-table tbody th span{font-weight: normal; font-size: 87.5%; color: #999; display: block;}
|
||||
|
||||
.wpos-plugin-pricing-table tbody td{background: #fff; text-align: center;}
|
||||
.wpos-plugin-pricing-table tbody td .dashicons{height: auto; width: auto; font-size:30px;}
|
||||
.wpos-plugin-pricing-table tbody td .dashicons-no-alt{color: #ff2700;}
|
||||
.wpos-plugin-pricing-table tbody td .dashicons-yes{color: #2ECC71;}
|
||||
|
||||
.wpos-plugin-pricing-table tbody tr:nth-child(even) th,
|
||||
.wpos-plugin-pricing-table tbody tr:nth-child(even) td { background: #f5f5f5; border: 1px solid #ccc; border-width: 1px 0 1px 1px; }
|
||||
.wpos-plugin-pricing-table tbody tr:last-child td {border-bottom: 0 none;}
|
||||
|
||||
/* Table Footer */
|
||||
.wpos-plugin-pricing-table tfoot th, .wpos-plugin-pricing-table tfoot td{text-align: center; border-top: 1px solid #ccc;}
|
||||
.wpos-plugin-pricing-table tfoot a, .wpos-plugin-pricing-table thead a{font-weight: 600; color: #fff; text-decoration: none; text-transform: uppercase; display: inline-block; padding: 1em 2em; background: #ff2700; border-radius: .2em;}
|
||||
|
||||
.wpos-epb{color:#ff2700 !important;}
|
||||
|
||||
/* SideBar */
|
||||
.wpos-sidebar .wpos-epb-wrap{background:#0055fb; color:#fff; padding:15px;}
|
||||
.wpos-sidebar .wpos-epb-wrap h2{font-size:24px !important; color:#fff; margin:0 0 15px 0; padding:0px !important;}
|
||||
.wpos-sidebar .wpos-epb-wrap h2 span{font-size:20px !important; color:#ffff00 !important;}
|
||||
.wpos-sidebar .wpos-epb-wrap ul li{font-size:16px; margin-bottom:8px;}
|
||||
.wpos-sidebar .wpos-epb-wrap ul li span{color:#ffff00 !important;}
|
||||
.wpos-sidebar .wpos-epb-wrap ul{list-style: decimal inside none;}
|
||||
.wpos-sidebar .wpos-epb-wrap b{font-weight:bold !important;}
|
||||
.wpos-sidebar .wpos-epb-wrap p{font-size:16px;}
|
||||
.wpos-sidebar .wpos-epb-wrap .button-yellow{font-weight: 600;color: #000; text-align:center;text-decoration: none;display:block;padding: 1em 2em;background: #ffff00;border-radius: .2em;}
|
||||
.wpos-sidebar .wpos-epb-wrap .button-orange{font-weight: 600;color: #fff; text-align:center;text-decoration: none;display:block;padding: 1em 2em;background: #ff2700;border-radius: .2em;}
|
||||
</style>
|
||||
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder">
|
||||
<div id="post-body-content">
|
||||
<table class="wpos-plugin-pricing-table">
|
||||
<colgroup></colgroup>
|
||||
<colgroup></colgroup>
|
||||
<colgroup></colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>
|
||||
<h2>Free</h2>
|
||||
</th>
|
||||
<th>
|
||||
<h2 class="wpos-epb">Premium</h2>
|
||||
<p>Gain access to <strong>WP Trending Post Slider and Widget</strong></p>
|
||||
<a href="<?php echo WTPSW_PLUGIN_UPGRADE; ?>" target="_blank">Buy Now</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td></td>
|
||||
<td><p>Gain access to <strong>Trending/Popular Post Slider and Widget</strong></p>
|
||||
<a href="<?php echo WTPSW_PLUGIN_UPGRADE; ?>" target="_blank">Buy Now</a>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Designs <span>Designs that make your website better</span></th>
|
||||
<td>3</i></td>
|
||||
<td>40+</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Shortcodes <span>Shortcode provide output to the front-end side</span></th>
|
||||
<td>3 (Slider, Carousel, Gridbox)</td>
|
||||
<td>8 (Grid, Slider, Carousel, Gridbox)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Shortcode Parameters <span>Add extra power to the shortcode</span></th>
|
||||
<td>15+</td>
|
||||
<td>25+</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Featured Post Support<span>Display featured posts as well.</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Custom Post Type Support<span>Display only registered post type posts. You can find it on plugin setting page.</span></th>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Shortcode Generator <span>Play with all shortcode parameters with preview panel. No documentation required!!</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>WP Templating Features <span>WP Templating Features You can modify plugin html/designs in your current theme.</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Gutenberg Block Supports <span>Use this plugin with Gutenberg easily</span></th>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Elementor Page Builder Support <em class="wpos-new-feature">New</em> <span>Use this plugin with Elementor easily</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Beaver Builder Support <em class="wpos-new-feature">New</em> <span>Use this plugin with Beaver Builder easily</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SiteOrigin Page Builder Support <em class="wpos-new-feature">New</em> <span>Use this plugin with SiteOrigin easily</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Divi Page Builder Native Support <em class="wpos-new-feature">New</em> <span>Use this plugin with Divi Builder easily</span></th>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Fusion Page Builder (Avada) native support <em class="wpos-new-feature">New</em> <span>Use this plugin with Fusion( Avada ) Builder easily</span></th>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>WPBakery Page Builder Support <span>Use this plugin with WPBakery Page Builder easily</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Widgets<span> WordPress Widgets to your sidebars.</span></th>
|
||||
<td>1</td>
|
||||
<td>6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Display Desired Post <span>Display only the post you want</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Display Post for Particular Categories <span>Display only the posts with particular category</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Display Post for Particular Author <span>Display only the posts with particular author</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Exclude Some Posts <span>Do not display the posts you want</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Exclude Some Categories <span>Do not display the posts for particular categories</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Exclude Some Author <span>Do not display the posts for particular author</span></th>
|
||||
<td><i class="dashicons dashicons-no-alt"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Post Order / Order By Parameters <span>Display post according to date, title and etc</span></th>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Multiple Slider Parameters <span>Slider parameters like autoplay, number of slide, sider dots and etc.</span></th>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Slider RTL Support <span>Slider supports for RTL website</span></th>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
<td><i class="dashicons dashicons-yes"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Automatic Update <span>Get automatic plugin updates </span></th>
|
||||
<td>Lifetime</td>
|
||||
<td>Lifetime</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Support <span>Get support for plugin</span></th>
|
||||
<td>Limited</td>
|
||||
<td>1 Year</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,301 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Premium Offer Page
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( !defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
?>
|
||||
<div class="wrap wpls-wrap">
|
||||
|
||||
<h2 class="text-center"><?php _e( 'Trending Popular with ', 'wtpsw' ); ?><span class="h-blue"><?php _e( 'Essential Plugin Bundle Free Trial', 'wtpsw' ); ?></span></h2>
|
||||
|
||||
<style>
|
||||
.button-orange { background: #FF5D52 !important; color: #fff !important; border: 2px solid #FF5D52 !important; font-size:18px!important; font-weight:bold; padding:10px 20px !important; }
|
||||
.section-space-medium{margin:15px 0;}
|
||||
.text-center{text-align:center;}
|
||||
.h-blue { color: #0055fb !important; margin-bottom: 0px !important;}
|
||||
.cart-section-header{font-size:26px; line-height:34px; margin:10px 0px;}
|
||||
.wpos-trail-main-table{background:#fff; width:100%;}
|
||||
.wpos-trail-main-table th, .wpos-trail-main-table td{padding:10px; text-align:left; border:1px solid #ddd; border-collapse: collapse;}
|
||||
.edd_checkout_cart_item_title{font-size:18px; font-weight:bold;}
|
||||
.wpos-trail-main-table tfoot th.edd_cart_total{text-align:right; font-size:18px; color:#0055fb;}
|
||||
.epb-list h5{margin:2px 0 !important;}
|
||||
.epb-list .dashicons {background: #aadb98;color: #34801a;font-size: 14px;padding: 2px;border-radius: 50%;margin-right: 5px; line-height:20px;}
|
||||
.epb-list li{margin-bottom:15px;}
|
||||
.page-template-free-trial-membership .wpos-bundle-stats .wpos-bundle-box {font-size:16px; margin-bottom:15px; box-shadow: 0 5px 30px 0 rgba(214,215,216,.57);padding: 20px 20px 20px 20px;background: #fff;position: relative;}
|
||||
.section-space-small{margin-bottom:20px;}
|
||||
.page-template-free-trial-membership .common-plan .wpos-bundle-stats .medium-4 .wpos-bundle-box{padding: 15px;}
|
||||
.common-plan img{width: 45px;height: 45px;margin-bottom: 8px;}
|
||||
.pay-later-cta {box-shadow: 0 5px 30px 0 rgba(214,215,216,.57);padding: 20px 20px 20px 20px;background: #fff;border-bottom: 2px solid #efeded;}
|
||||
.pricing-review-wrap span{font-size: 14px;}
|
||||
.page-template-free-trial-membership .wpos-seam-integration li{width: 32%;display: inline-block;}
|
||||
.page-template-free-trial-membership .epb-list li{margin-bottom: 0;line-height: 34px;}
|
||||
.page-template-free-trial-membership .wpos-checkout-right .epb-list li{line-height: 26px;}
|
||||
.page-template-free-trial-membership .wp-builder-list li a{display: table;}
|
||||
.page-template-free-trial-membership .wp-builder-list li a img{display: table-cell;width: 50px;}
|
||||
.page-template-free-trial-membership .wp-builder-list li a span{vertical-align: middle;display: table-cell;padding-left: 10px;line-height: normal;}
|
||||
.page-template-free-trial-membership .wpos-pricing-faq-page ul{max-width: 650px;margin: 0 auto;}
|
||||
.grid-x:before, .grid-x:after{content: "";display: table;}
|
||||
.grid-x::after, .grid-x{clear: both;}
|
||||
.grid-padding-x{ margin-right: -.9375rem; margin-left: -.9375rem;}
|
||||
|
||||
@media only screen and (max-width: 40em) {
|
||||
.page-template-free-trial-membership .pricing-review-wrap .medium-3{margin-bottom: 15px;}
|
||||
.page-template-free-trial-membership .wpos-seam-integration li{width: 100%;}
|
||||
.page-template-free-trial-membership .wpos-seam-integration li ul.epb-list li{border: none !important;}
|
||||
.page-template-free-trial-membership .wpos-pricing-faq-page .accordion-item a{font-size: 16px;line-height: normal;}
|
||||
.page-template-free-trial-membership .medium-4.wpos-checkout-right img{max-width: 200px;margin: 0 auto 20px;display: block;width: 100%;}
|
||||
.common-plan .medium-2{width: 100%;}
|
||||
}
|
||||
@media only screen and (min-width: 40em) {
|
||||
.cell {padding-right: .9375rem; padding-left: .9375rem; float:left; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
|
||||
.medium-12{ width: 100%; }
|
||||
.medium-8{ width: 66.66667%; }
|
||||
.medium-4{ width: 33.333%; }
|
||||
.medium-3{ width:25%; }
|
||||
.medium-2{ width: 20%; }
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder page-template-free-trial-membership">
|
||||
<div id="post-body-content">
|
||||
<div class="grid-x grid-padding-x">
|
||||
<div class="small-12 medium-8 cell">
|
||||
<div class="wpos-trail-table">
|
||||
<table class="wpos-trail-main-table">
|
||||
<thead>
|
||||
<tr class="edd_cart_header_row">
|
||||
<th class="edd_cart_item_name">0$ Pro Trial</th>
|
||||
<th class="edd_cart_item_price">Item Price</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="edd_cart_item" id="edd_cart_item_0_106568" data-download-id="106568">
|
||||
<td class="edd_cart_item_name">
|
||||
<span class="edd_checkout_cart_item_title">14 Days Pro Essential Plugin Bundle – 0$ Pro Trial - Unlimited Sites</span>
|
||||
<p class="eddr-notice eddr-cart-item-notice" style="margin-bottom: 0 !important;"><em style="font-weight:bold; font-size:13px;line-height: normal;">* <span class="h-blue">After 14-Days</span> 0$ Pro Trial $149 will be billed annually.</em></p>
|
||||
<p class="eddr-notice h-orange eddr-cart-item-notice"><em style="font-weight:bold; font-size:13px; ">* <span class="h-blue">Within 14-Days </span>0$ Pro Trial easily cancelable and you will not be charge at all.</em></p>
|
||||
</td>
|
||||
<td class="edd_cart_item_price">$149.00
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="edd_cart_footer_row">
|
||||
<th colspan="2" class="edd_cart_total">Total: <span class="edd_cart_amount" data-subtotal="149" data-total="149">$0.00</span></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div class="grid-x grid-padding-x" style="text-align: center;width: 100%;padding: 30px 0;">
|
||||
<div class="small-12 medium-6" style="display: inline-block; font-weight: bold;border-right: 1px solid #ddd;text-align: center;">
|
||||
<span class="h-blue" style="font-size: 40px;margin-right: 10px;">277</span> <span style="display: inline-block;color: #505050;max-width: 100px;line-height: normal;text-align: left;font-size: 15px;">Trials in the last month</span>
|
||||
</div>
|
||||
<div class="small-12 medium-6" style="display: inline-block; font-weight: bold;text-align: center;">
|
||||
<span class="h-blue" style="font-size: 40px;margin-right: 10px;">16,435</span> <span style="display: inline-block;color: #505050;max-width: 100px;line-height: normal;text-align: left;font-size: 15px;">Pro-users since 2015</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="small-12 medium-4 cell wpos-checkout-right">
|
||||
<h4 class="cart-section-header">14 Days Pro Essential Plugin Bundle – <span style="color: #0055fb ;">0$ Pro Trial</span></h4>
|
||||
<h5 style="font-size: 18px;line-height: 30px;margin: 10px 0px;">Your Plan Details:</h5>
|
||||
<ul style="margin: 0;list-style: none;font-size: 16px;">
|
||||
<li style="margin-bottom:8px;">
|
||||
<span style="display:inline-block;vertical-align: middle;"><img src="<?php echo WTPSW_URL; ?>/assets/images/utility-50.png" width="24"></span> <span style="display:inline-block;vertical-align: middle;">39 Utility Plugins</span>
|
||||
</li>
|
||||
<li style="margin-bottom:8px;">
|
||||
<span style="display:inline-block;vertical-align: middle;"><img src="<?php echo WTPSW_URL; ?>/assets/images/inboundwp-50.png" width="24"></span> <span style="display:inline-block;vertical-align: middle;">6 Marketing Tools</span>
|
||||
</li>
|
||||
<li style="margin-bottom:8px;">
|
||||
<span style="display:inline-block;vertical-align: middle;"><img src="<?php echo WTPSW_URL; ?>/assets/images/SlidersPack-50.png" width="24"></span><span style="display:inline-block;vertical-align: middle;"> 10 SlidersPack</span>
|
||||
</li>
|
||||
<li style="margin-bottom:8px;">
|
||||
<span style="display:inline-block;vertical-align: middle;"><img src="<?php echo WTPSW_URL; ?>/assets/images/popup-anything-icon.png" width="24"></span><span style="display:inline-block;vertical-align: middle;"> Popup Anything A Marketing Popup</span>
|
||||
</li>
|
||||
<li>
|
||||
<span style="display:inline-block;vertical-align: middle;"><img src="<?php echo WTPSW_URL; ?>/assets/images/security-icon.png" width="24"></span><span style="display:inline-block;vertical-align: middle;"> Essential Security</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="small-12 medium-12 cell text-center section-space-medium">
|
||||
<a href="<?php echo WTPSW_CHECKOUT_PLUGIN_LINK; ?>" class="large button button-orange radius" target="_blank">Join 0$ 14 Days Pro Bundle Trial</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid-x grid-padding-x" style="margin:30px 0;">
|
||||
<div class="medium-12 cell text-center">
|
||||
<h3 class="text-center cart-section-header" style="display: inline-block;">Build <span style="background:#0099fb;color:#fff;padding: 0 5px;">better websites</span>, <span style="background:#0099fb;color:#fff;padding: 0 5px;">landing pages</span> & <span style="background:#0099fb;color:#fff;padding: 0 5px;">conversion flow</span></h3>
|
||||
</div>
|
||||
<div class="text-center medium-12 cell epb-list">
|
||||
<ul style="list-style:none;margin-left: 0;">
|
||||
<li>
|
||||
<h5 style="font-size:17px;"><span class="dashicons dashicons-saved"></span></i>45 plugins, 10 sliders, Best in class - Popup plugin<span class="new-badge" style="position: relative;top: -8px;right: 2px;font-size: 10px;">New</span> with 2000+ pre-built templates in <span class="h-blue">Essential Bundle</span></h5>
|
||||
</li>
|
||||
<li>
|
||||
<h5 style="font-size:17px;line-height: 30px;margin-bottom: 6px !important;"><span class="dashicons dashicons-saved"></span> Compatible with <span style="text-decoration: underline;color: #ff5d52;">Gutenberg, DIVI, Elementor, Avada, VC/WPbakery</span> etc page builder/themes</h5>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid-x grid-padding-x wpos-bundle-stats">
|
||||
<div class="small-12 medium-12 cell text-center section-space-small">
|
||||
<h3 class="cart-section-header text-center">What You Will Get?</h3>
|
||||
</div>
|
||||
<div class="medium-2 small-12 cell">
|
||||
<div class="wpos-bundle-box text-center">
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/utility-50.png"><br>
|
||||
39 <br>
|
||||
Utility Plugins
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-2 small-12 cell">
|
||||
<div class="wpos-bundle-box text-center">
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/inboundwp-50.png"><br>
|
||||
6 <br>
|
||||
Marketing Tools
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-2 small-12 cell">
|
||||
<div class="wpos-bundle-box text-center">
|
||||
<img src="<?php echo WTPSW_URL; ?>assets/images/SlidersPack-50.png"><br>
|
||||
10 <br>
|
||||
SlidersPack
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-2 small-12 cell">
|
||||
<div class="wpos-bundle-box text-center">
|
||||
<img src="<?php echo WTPSW_URL; ?>assets/images/popup-anything-icon.png"><br>
|
||||
Popup Anything <br>
|
||||
A Marketing Popup
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-2 small-12 cell">
|
||||
<div class="wpos-bundle-box text-center">
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/security-icon.png"><br>
|
||||
Essential <br>Security
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-4 small-12 cell">
|
||||
<div class="wpos-bundle-box text-center">
|
||||
2000+ Templates
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-4 small-12 cell">
|
||||
<div class="wpos-bundle-box text-center">
|
||||
Regular Updates With Valid Subscription
|
||||
</div>
|
||||
</div>
|
||||
<div class="medium-4 small-12 cell">
|
||||
<div class="wpos-bundle-box text-center">
|
||||
Auto Renewal Yearly Product License
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="pay-later-cta text-center section-space-medium" style="font-size: 28px;"><span style="color:#ed4635;">PAY $0 USD</span> + <span style="color:#5f9654;">INSTALL</span> + <span style="color:#9d42b0;">USE & EXPLORE</span> = <span class="h-blue">YOUR DECISION YOU PAY OR NOT</span></h3>
|
||||
<div class="pricing-review-wrap text-center section-space-medium" style="padding:30px 0;background-color: #eaf1fe;">
|
||||
<div class="grid-container">
|
||||
<h4 class="section-space-small cart-section-header">Get convinced? Check out what our real-life members have to say...</h4>
|
||||
<div class="grid-x grid-padding-x">
|
||||
<div class="small-12 medium-3 cell text-center">
|
||||
<a href="https://tinyurl.com/y4bh9dnn" target="_blank" style="display: block;">
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/g-logo.png" width="44">
|
||||
<br>
|
||||
<span style="color:#555">Google Reviews</span><br>
|
||||
<span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><br>
|
||||
<span>150+ reviews</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="small-12 medium-3 cell">
|
||||
<a href="https://www.facebook.com/EssentialPlugins/reviews/" target="_blank" style="display: block;">
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/fb-icon.png" width="44">
|
||||
<br>
|
||||
<span style="color:#555">Facebook Reviews</span><br>
|
||||
<span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><br>
|
||||
<span>50+ reviews</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="small-12 medium-3 cell" style="padding-top: 10px;">
|
||||
<a href="https://profiles.wordpress.org/wponlinesupport/#content-plugins" target="_blank" style="display: block;">
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/wordpress-icon-logo.png" width="150">
|
||||
<br>
|
||||
<span style="color:#555">WordPress.org Reviews</span><br>
|
||||
<span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><br>
|
||||
<span>500+ reviews</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="small-12 medium-3 cell" style="padding-top:10px;">
|
||||
<a href="https://www.essentialplugin.com/essential-plugin-bundle-testimonials/" target="_blank" style="display: block;">
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/essential-plugin-logo.png" width="150">
|
||||
<br>
|
||||
<span style="color:#555">On-Site Reviews</span><br>
|
||||
<span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><span class="dashicons dashicons-star-filled" style="color: #fe8f01;"></span><br>
|
||||
<span>200+ reviews</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center section-space-larger">
|
||||
<a href="<?php echo WTPSW_CHECKOUT_PLUGIN_LINK; ?>" class="large button button-orange radius" target="_blank">Join 0$ 14 Days Pro Bundle Trial</a>
|
||||
<ul class="epb-list" style="text-align: left;list-style: none;margin: 0 auto;padding: 0 15px;max-width: 500px;">
|
||||
<li><span class="dashicons dashicons-saved"></span><span class="h-orange">After 14 days - 0$ Pro Trial $149 will be billed annually.</span></li>
|
||||
<li><span class="dashicons dashicons-saved"></span><span class="h-orange">Within 14 days 0$ Pro Trial easily cancelable and you will not be charge at all.</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="wpos-seam-integration" class="wpos-seam-integration section-space-medium">
|
||||
<div class="grid-x grid-padding-x">
|
||||
<div class="small-12 medium-12 cell text-center section-space-small">
|
||||
<h4 class="h-blue cart-section-header">Seamless Integration With All Major Page Builders</h4>
|
||||
<h3 class="cart-section-header">+ Multisite, Ecom Compatible</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid-container">
|
||||
<div class="grid-x grid-padding-x">
|
||||
<div class="small-12 medium-12 cell section-space-small">
|
||||
<ul class="wp-builder-list" style="list-style:none;margin:0;">
|
||||
<li>
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/gutenberg-icon.png" width="30"><span style="margin-left: 10px;">Gutenberg Page Builder</span>
|
||||
</li>
|
||||
<li>
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/site-origin-icon.png" width="30"><span style="margin-left: 10px;">Siteorigin Page Builder</span>
|
||||
</li>
|
||||
<li>
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/elementor-icon.png" width="30"><span style="margin-left: 10px;">Elementor Page Builder</span>
|
||||
</li>
|
||||
<li>
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/vc-icon.png" width="30"><span style="margin-left: 10px;">VC Composer Page Builder</span>
|
||||
</li>
|
||||
<li>
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/wpbakery-icon.png" width="30"><span style="margin-left: 10px;">WPbakery Page Builder</span>
|
||||
</li>
|
||||
<li>
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/beaver-icon.png" width="30"><span style="margin-left: 10px;">Beaver Page Builder</span>
|
||||
</li>
|
||||
<li>
|
||||
<img src="<?php echo WTPSW_URL; ?>/assets/images/divi-icon.png" width="30"><span style="margin-left: 10px;">Adding DIVI and Avada theme support</span>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<div class="small-12 medium-12 cell text-center">
|
||||
<a href="<?php echo WTPSW_CHECKOUT_PLUGIN_LINK; ?>" class="large button button-orange radius" target="_blank">Join 0$ 14 Days Pro Bundle Trial</a>
|
||||
<ul class="epb-list" style="text-align: left;list-style: none;max-width: 500px;margin: 0 auto;padding: 0;">
|
||||
<li style="line-height: 34px;width: 100%;padding: 0;margin: 0;"><span class="dashicons dashicons-saved"></span><span class="h-orange">After 14 days - 0$ Pro Trial $149 will be billed annually.</span></li>
|
||||
<li style="line-height: 34px;width: 100%;padding: 0;margin: 0;"><span class="dashicons dashicons-saved"></span><span class="h-orange">Within 14 days 0$ Pro Trial easily cancelable and you will not be charge at all.</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Settings Page
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
$reg_post_types = wtpsw_get_post_types();
|
||||
$tp_support_post_types = wtpsw_get_option( 'post_types', array() );
|
||||
?>
|
||||
|
||||
<div class="wrap wtpsw-settings">
|
||||
|
||||
<h2><?php _e( 'Trending Post - Settings', 'wtpsw' ); ?></h2>
|
||||
|
||||
<?php
|
||||
if( isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' ) {
|
||||
echo '<div id="message" class="updated notice notice-success is-dismissible">
|
||||
<p>'.__("Your changes saved successfully.", "wtpsw").'</p>
|
||||
</div>';
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="options.php" method="POST" id="wtpsw-settings-form" class="wtpsw-settings-form">
|
||||
|
||||
<?php
|
||||
settings_fields( 'wtpsw_plugin_options' );
|
||||
global $wtpsw_options;
|
||||
?>
|
||||
|
||||
<div id="wtpsw-general-settings" class="post-box-container wtpsw-general-settings">
|
||||
<div class="metabox-holder">
|
||||
<div class="meta-box-sortables ui-sortable">
|
||||
<div id="general" class="postbox">
|
||||
<div class="postbox-header">
|
||||
<h2 class="hndle">
|
||||
<span><?php _e( 'General Settings', 'wtpsw' ); ?></span>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="inside">
|
||||
<table class="form-table wtpsw-general-settings-tbl">
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="wtpsw-post-within"><?php _e('Post Within', 'wtpsw'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<select id="wtpsw-post-within" class="wtpsw-post-within" name="wtpsw_options[post_range]">
|
||||
<option value=""><?php _e('All Time', 'wtpsw'); ?></option>
|
||||
<option value="daily" <?php selected( $wtpsw_options['post_range'], 'daily' ); ?>><?php _e('Today', 'wtpsw'); ?></option>
|
||||
<option value="last_day" <?php selected( $wtpsw_options['post_range'], 'last_day' ); ?>><?php _e('Last Day', 'wtpsw'); ?></option>
|
||||
<option value="last_week" <?php selected( $wtpsw_options['post_range'], 'last_week' ); ?>><?php _e('Last 7 Days', 'wtpsw'); ?></option>
|
||||
<option value="last_month" <?php selected( $wtpsw_options['post_range'], 'last_month' ); ?>><?php _e('Last Month', 'wtpsw'); ?></option>
|
||||
</select><br/>
|
||||
<span class="description"><?php _e('Select time range for post visibility. Note: The post published within this time range will be visible.', 'wtpsw'); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>
|
||||
<label for="select-post-type"><?php _e('Select Post Types', 'wtpsw'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<?php if( !empty($reg_post_types) ) {
|
||||
foreach ($reg_post_types as $post_key => $post_label) { ?>
|
||||
<div class="ftpp-post-type-wrap">
|
||||
<label>
|
||||
<input type="checkbox" id="ftpp-tp-post-<?php echo $post_key; ?>" value="<?php echo $post_key; ?>" name="wtpsw_options[post_types][]" <?php checked( in_array($post_key, $tp_support_post_types), true ); ?> />
|
||||
<?php echo $post_label; ?>( <?php echo __('Post Type','wtpsw').' : '.$post_key; ?> )
|
||||
</label>
|
||||
</div>
|
||||
<?php }
|
||||
} ?>
|
||||
<span class="description"><?php _e('Select post type box for trending post. You can enter post type name in shortcode parameter.', 'wtpsw'); ?></span> <br/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2" valign="top" scope="row">
|
||||
<input type="submit" id="wtpsw-settings-submit" name="wtpsw-settings-submit" class="button button-primary right" value="<?php _e('Save Changes','wtpsw');?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div><!-- .inside -->
|
||||
</div><!-- #general -->
|
||||
|
||||
</div><!-- .meta-box-sortables ui-sortable -->
|
||||
</div><!-- .metabox-holder -->
|
||||
</div><!-- #wtpsw-general-settings -->
|
||||
|
||||
</form><!-- end .wtpsw-settings-form -->
|
||||
|
||||
</div><!-- end .wtpsw-settings -->
|
@ -0,0 +1,288 @@
|
||||
<?php
|
||||
/**
|
||||
* Blocks Initializer
|
||||
*
|
||||
* @package Trending/Popular Post Slider and Widget
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
function wtpsw_register_guten_block() {
|
||||
|
||||
// Block Editor Script
|
||||
wp_register_script( 'wtpsw-block-js', WTPSW_URL.'assets/js/blocks.build.js', array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-block-editor', 'wp-components' ), WTPSW_VERSION, true );
|
||||
wp_localize_script( 'wtpsw-block-js', 'Wtpsw_Block', array(
|
||||
'pro_demo_link' => 'https://demo.wponlinesupport.com/prodemo/pro-featured-and-trending-post/',
|
||||
'free_demo_link' => 'https://demo.wponlinesupport.com/trending-post-demo/',
|
||||
'pro_link' => WTPSW_PLUGIN_LINK,
|
||||
));
|
||||
|
||||
// Register block and explicit attributes for trending slider
|
||||
register_block_type( 'wtpsw-free/trending-slider', array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'default' => '',
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
'default' => '',
|
||||
),
|
||||
'showdate' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'showauthor' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'show_comment_count' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'hide_empty_comment_count' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'showcontent' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'words_limit' => array(
|
||||
'type' => 'number',
|
||||
'default' => 40,
|
||||
),
|
||||
'dots' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'true',
|
||||
),
|
||||
'arrows' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'true',
|
||||
),
|
||||
'autoplay' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'true',
|
||||
),
|
||||
'autoplayinterval' => array(
|
||||
'type' => 'number',
|
||||
'default' => 3000,
|
||||
),
|
||||
'speed' => array(
|
||||
'type' => 'number',
|
||||
'default' => 300,
|
||||
),
|
||||
'limit' => array(
|
||||
'type' => 'number',
|
||||
'default' => 10,
|
||||
),
|
||||
'post_type' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'post',
|
||||
),
|
||||
'view_by' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'views',
|
||||
),
|
||||
'order' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'desc',
|
||||
),
|
||||
),
|
||||
'render_callback' => 'wtpsw_trending_post_slider',
|
||||
));
|
||||
|
||||
|
||||
// Register block and explicit attributes for trending carousel
|
||||
register_block_type( 'wtpsw-free/trending-carousel', array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'default' => '',
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
'default' => '',
|
||||
),
|
||||
'showdate' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'showauthor' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'show_comment_count' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'hide_empty_comment_count' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'showcontent' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'words_limit' => array(
|
||||
'type' => 'number',
|
||||
'default' => 40,
|
||||
),
|
||||
'slides_to_show' => array(
|
||||
'type' => 'number',
|
||||
'default' => 3,
|
||||
),
|
||||
'slides_to_scroll' => array(
|
||||
'type' => 'number',
|
||||
'default' => 1,
|
||||
),
|
||||
'dots' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'true',
|
||||
),
|
||||
'arrows' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'true',
|
||||
),
|
||||
'autoplay' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'true',
|
||||
),
|
||||
'autoplayinterval' => array(
|
||||
'type' => 'number',
|
||||
'default' => 3000,
|
||||
),
|
||||
'speed' => array(
|
||||
'type' => 'number',
|
||||
'default' => 300,
|
||||
),
|
||||
'limit' => array(
|
||||
'type' => 'number',
|
||||
'default' => 10,
|
||||
),
|
||||
'post_type' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'post',
|
||||
),
|
||||
'view_by' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'views',
|
||||
),
|
||||
'order' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'DESC',
|
||||
),
|
||||
|
||||
),
|
||||
'render_callback' => 'wtpsw_popular_post_carousel',
|
||||
));
|
||||
|
||||
// Register block and explicit attributes for trending gridbox
|
||||
register_block_type( 'wtpsw-free/trending-gridbox', array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'default' => '',
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
'default' => '',
|
||||
),
|
||||
'showdate' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'showauthor' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'show_comment_count' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'hide_empty_comment_count' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'showcontent' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'words_limit' => array(
|
||||
'type' => 'number',
|
||||
'default' => 40,
|
||||
),
|
||||
'limit' => array(
|
||||
'type' => 'number',
|
||||
'default' => 5,
|
||||
),
|
||||
'post_type' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'post',
|
||||
),
|
||||
'view_by' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'views',
|
||||
),
|
||||
'order' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'DESC',
|
||||
),
|
||||
),
|
||||
'render_callback' => 'wtpsw_trending_post_gridbox',
|
||||
));
|
||||
|
||||
if ( function_exists( 'wp_set_script_translations' ) ) {
|
||||
wp_set_script_translations( 'wtpsw-block-js', 'wtpsw', WTPSW_DIR . '/languages' );
|
||||
}
|
||||
}
|
||||
add_action( 'init', 'wtpsw_register_guten_block' );
|
||||
|
||||
/**
|
||||
* Enqueue Gutenberg block assets for backend editor.
|
||||
*
|
||||
* @uses {wp-blocks} for block type registration & related functions.
|
||||
* @uses {wp-element} for WP Element abstraction — structure of blocks.
|
||||
* @uses {wp-i18n} to internationalize the block's text.
|
||||
* @uses {wp-editor} for WP editor styles.
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0
|
||||
*/
|
||||
function wtpsw_editor_assets() {
|
||||
|
||||
// Block Editor CSS
|
||||
if( ! wp_style_is( 'wpos-guten-block-css', 'registered' ) ) {
|
||||
wp_register_style( 'wpos-guten-block-css', WTPSW_URL.'assets/css/blocks.editor.build.css', array( 'wp-edit-blocks' ), WTPSW_VERSION );
|
||||
}
|
||||
|
||||
// Block Editor Script
|
||||
wp_enqueue_style( 'wpos-guten-block-css' );
|
||||
wp_enqueue_script( 'wtpsw-block-js' );
|
||||
}
|
||||
add_action( 'enqueue_block_editor_assets', 'wtpsw_editor_assets' );
|
||||
|
||||
/**
|
||||
* Adds an extra category to the block inserter
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0
|
||||
*/
|
||||
function wtpsw_add_block_category( $categories ) {
|
||||
|
||||
$guten_cats = wp_list_pluck( $categories, 'slug' );
|
||||
|
||||
if( ! in_array( 'wpos_guten_block', $guten_cats ) ) {
|
||||
$categories[] = array(
|
||||
'slug' => 'wpos_guten_block',
|
||||
'title' => __('WPOS Blocks', 'wtpsw'),
|
||||
'icon' => null,
|
||||
);
|
||||
}
|
||||
|
||||
return $categories;
|
||||
}
|
||||
add_filter( 'block_categories_all', 'wtpsw_add_block_category' );
|
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* Pro Designs and Plugins Feed
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wrap wtpsw-wrap">
|
||||
<style type="text/css">
|
||||
.wpos-pro-box .hndle{background-color:#0073AA; color:#fff;}
|
||||
.wpos-pro-box .postbox{background:#dbf0fa none repeat scroll 0 0; border:1px solid #0073aa; color:#191e23;}
|
||||
.postbox-container .wpos-list li:before{font-family: dashicons; content: "\f139"; font-size:20px; color: #0073aa; vertical-align: middle;}
|
||||
.wtpsw-wrap .wpos-button-full{display:block; text-align:center; box-shadow:none; border-radius:0;}
|
||||
.wtpsw-shortcode-preview{background-color: #e7e7e7; font-weight: bold; padding: 2px 5px; display: inline-block; margin:0 0 2px 0;}
|
||||
.upgrade-to-pro{font-size:18px; text-align:center; margin-bottom:15px;}
|
||||
.wpos-copy-clipboard{-webkit-touch-callout: all; -webkit-user-select: all; -khtml-user-select: all; -moz-user-select: all; -ms-user-select: all; user-select: all;}
|
||||
.wpos-new-feature{ font-size: 10px; margin-left:2px; color: #fff; font-weight: bold; background-color: #03aa29; padding:1px 4px; font-style: normal; }
|
||||
.button-orange{background: #ff2700 !important;border-color: #ff2700 !important; font-weight: 600;}
|
||||
</style>
|
||||
<h2><?php _e( 'How It Works', 'wtpsw' ); ?></h2>
|
||||
<div class="post-box-container">
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
<!--How it workd HTML -->
|
||||
<div id="post-body-content">
|
||||
<div class="metabox-holder">
|
||||
<div class="meta-box-sortables">
|
||||
<div class="postbox">
|
||||
<div class="postbox-header">
|
||||
<h2 class="hndle">
|
||||
<span><?php _e( 'Need Support & Solutions?', 'wtpsw' ); ?></span>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="inside">
|
||||
<p><?php _e('Boost design and best solution for your website.', 'wtpsw'); ?></p>
|
||||
<a class="button button-primary button-orange" href="<?php echo WTPSW_PLUGIN_LINK; ?>" target="_blank"><?php _e('Grab Now', 'wtpsw'); ?></a>
|
||||
</div><!-- .inside -->
|
||||
</div><!-- #general -->
|
||||
|
||||
<div class="postbox">
|
||||
<div class="postbox-header">
|
||||
<h2 class="hndle">
|
||||
<span><?php _e( 'How It Works - Display and Shortcode', 'wtpsw' ); ?></span>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="inside">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th>
|
||||
<label><?php _e('Getting Started', 'wtpsw'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<p><?php _e('Trending Post display most visited post on your website. It works with WordPress default post type.', 'wtpsw'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<label><?php _e('All Shortcodes', 'wtpsw'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<span class="wpos-copy-clipboard wtpsw-shortcode-preview">[wtpsw_popular_post]</span> – <?php _e('Trending Post Slider View', 'wtpsw'); ?><br />
|
||||
<span class="wpos-copy-clipboard wtpsw-shortcode-preview">[wtpsw_carousel]</span> – <?php _e('Trending Post Carousel View', 'wtpsw'); ?><br />
|
||||
<span class="wpos-copy-clipboard wtpsw-shortcode-preview">[wtpsw_gridbox]</span> – <?php _e('Trending Post Gridbox View', 'wtpsw'); ?>
|
||||
<br/><br/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<label><?php _e('Documentation', 'wtpsw'); ?>:</label>
|
||||
</th>
|
||||
<td>
|
||||
<a class="button button-primary" href="https://docs.essentialplugin.com/trending-popular-post-slider-and-widget/" target="_blank"><?php _e('Check Documentation', 'wtpsw'); ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="postbox">
|
||||
<div class="postbox-header">
|
||||
<h2 class="hndle">
|
||||
<span><?php _e( 'Gutenberg Support', 'wp-testimonial-with-widget' ); ?></span>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="inside">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
<label><?php _e('How it Work', 'wp-testimonial-with-widget'); ?>:</label>
|
||||
</th>
|
||||
<td>
|
||||
<ul>
|
||||
<li><?php _e('Step-1. Go to the Gutenberg editor of your page.', 'wp-testimonial-with-widget'); ?></li>
|
||||
<li><?php _e('Step-2. Search "testimonial" keyword in the gutenberg block list.', 'wp-testimonial-with-widget'); ?></li>
|
||||
<li><?php _e('Step-3. Add any block of testimonial and you will find its relative options on the right end side.', 'wp-testimonial-with-widget'); ?></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div><!-- .inside -->
|
||||
</div><!-- #general -->
|
||||
|
||||
<div class="postbox">
|
||||
<div class="postbox-header">
|
||||
<h2 class="hndle">
|
||||
<span><?php _e( 'Help to improve this plugin!', 'wtpsw' ); ?></span>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="inside">
|
||||
<p><?php _e('Enjoyed this plugin? You can help by rate this plugin', 'wtpsw'); ?> <a href="https://wordpress.org/support/plugin/wp-trending-post-slider-and-widget/reviews#new-post" target="_blank"><?php _e('5 stars!', 'wtpsw'); ?></a></p>
|
||||
</div><!-- .inside -->
|
||||
</div><!-- #general -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Upgrad to Pro HTML -->
|
||||
<div id="postbox-container-1" class="postbox-container">
|
||||
<div class="metabox-holder wpos-pro-box">
|
||||
<div class="meta-box-sortables">
|
||||
<div class="postbox">
|
||||
<h3 class="hndle">
|
||||
<span><?php _e( 'Upgrate to Pro', 'wtpsw' ); ?></span>
|
||||
</h3>
|
||||
<div class="inside">
|
||||
<ul class="wpos-list">
|
||||
<li>40+ stunning and cool designs for Grid, slider, carousel and gridbox</li>
|
||||
<li>8 shortcodes</li>
|
||||
<li>Visual Composer Page Builder Support</li>
|
||||
<li>6 different types of widgets</li>
|
||||
<li>Custom post type support</li>
|
||||
<li>Gutenberg Block Supports.</li>
|
||||
<li>WPBakery Page Builder Supports</li>
|
||||
<li>Elementor, Beaver and SiteOrigin Page Builder Support. <span class="wpos-new-feature">New</span></li>
|
||||
<li>Divi Page Builder Native Support. <span class="wpos-new-feature">New</span></li>
|
||||
<li>Fusion Page Builder (Avada) native support.<span class="wpos-new-feature">New</span></li>
|
||||
<li>WP Templating Features</li>
|
||||
<li>Display Desired post include and exclude </li>
|
||||
<li>Display posts with include categories and exclude categories</li>
|
||||
<li>Display posts with particular include author and exclude author</li>
|
||||
<li>Custom CSS</li>
|
||||
<li>100% Multi language</li>
|
||||
</ul>
|
||||
<div class="upgrade-to-pro">Gain access to <strong>WP Trending Post Slider and Widget</strong> included in <br /><strong>Essential Plugin Bundle</div>
|
||||
<a class="button button-primary wpos-button-full button-orange" href="<?php echo WTPSW_PLUGIN_LINK; ?>" target="_blank"><?php _e('Grab Now', 'wtpsw'); ?></a>
|
||||
</div><!-- .inside -->
|
||||
</div><!-- #general -->
|
||||
</div><!-- .meta-box-sortables -->
|
||||
</div><!-- .metabox-holder -->
|
||||
</div><!-- #post-container-1 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* Model Class
|
||||
*
|
||||
* Handles query related functionality of plugin
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Wtpsw_Model {
|
||||
|
||||
function __construct(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get post data
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_get_posts( $args = array() ) {
|
||||
|
||||
// Taking defaults
|
||||
$result_data = array();
|
||||
|
||||
$postsargs['post_status'] = array( 'publish' );
|
||||
$postsargs['post_type'] = !empty($args['post_type']) ? $args['post_type'] : 'post';
|
||||
$postsargs['posts_per_page'] = !empty($args['posts_per_page']) ? $args['posts_per_page'] : -1;
|
||||
|
||||
// Order by records
|
||||
$postsargs['order'] = !empty($args['order']) ? $args['order'] : 'DESC';
|
||||
$postsargs['orderby'] = !empty($args['orderby']) ? $args['orderby'] : 'date';
|
||||
|
||||
// Meta key
|
||||
if(isset($args['meta_key']) && !empty($args['meta_key'])) {
|
||||
$postsargs['meta_key'] = $args['meta_key'];
|
||||
}
|
||||
|
||||
// Per page records
|
||||
if(isset($args['paged']) && !empty($args['paged'])) {
|
||||
$postsargs['paged'] = $args['paged'];
|
||||
}
|
||||
|
||||
// Meta query
|
||||
if(isset($args['meta_query']) && !empty($args['meta_query'])) {
|
||||
$postsargs['meta_query'] = $args['meta_query'];
|
||||
}
|
||||
|
||||
// Taxonomy query
|
||||
if(isset($args['tax_query']) && !empty($args['tax_query'])) {
|
||||
$postsargs['tax_query'] = $args['tax_query'];
|
||||
}
|
||||
|
||||
// Date query
|
||||
if(isset($args['date_query']) && !empty($args['date_query'])) {
|
||||
$postsargs['date_query'] = $args['date_query'];
|
||||
}
|
||||
|
||||
// Run WP Query
|
||||
$result = new WP_Query( $postsargs );
|
||||
|
||||
// If only want to get count
|
||||
if(isset($args['getcount']) && $args['getcount'] == '1') {
|
||||
$result_data = $result->post_count;
|
||||
} elseif ( isset($args['list_data']) && !empty($args['list_data']) ) { // Data with post and count in array format
|
||||
|
||||
// Converting retrived post data to array
|
||||
$result_data = wtpsw_object_to_array($result->posts);
|
||||
|
||||
// Fetch data with count
|
||||
if( isset($args['list_data']) && !empty($args['list_data']) ) {
|
||||
|
||||
$data_res = array();
|
||||
|
||||
$data_res['data'] = $result_data;
|
||||
|
||||
// To get total count of post
|
||||
$data_res['total'] = isset($result->found_posts) ? $result->found_posts : '';
|
||||
|
||||
// Assigning it in to returned array
|
||||
$result_data = $data_res;
|
||||
}
|
||||
|
||||
} else { // Simply pass whole query
|
||||
$result_data = $result;
|
||||
}
|
||||
|
||||
return $result_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to modify query where
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_query_where( $where = '' ) {
|
||||
|
||||
global $wpdb, $wtpsw_options, $wtpsw_view_by;
|
||||
|
||||
$current_date = current_time('timestamp');
|
||||
$post_range = isset($wtpsw_options['post_range']) ? $wtpsw_options['post_range'] : '';
|
||||
|
||||
switch ($post_range) {
|
||||
case 'daily':
|
||||
$start_date = date( 'Y-m-d', $current_date );
|
||||
|
||||
$where_con = " AND DATE($wpdb->posts.post_date) = '{$start_date}' ";
|
||||
break;
|
||||
|
||||
case 'last_day':
|
||||
$start_date = date( 'Y-m-d', strtotime( '-1 days', $current_date ) );
|
||||
|
||||
$where_con = " AND DATE($wpdb->posts.post_date) = '{$start_date}' ";
|
||||
break;
|
||||
|
||||
case 'last_week':
|
||||
$start_date = date( 'Y-m-d', strtotime( '-7 days', $current_date ) );
|
||||
$end_date = date( 'Y-m-d', $current_date );
|
||||
|
||||
$where_con = " AND DATE($wpdb->posts.post_date) > '{$start_date}' AND DATE($wpdb->posts.post_date) <= '{$end_date}'";
|
||||
break;
|
||||
|
||||
case 'last_month':
|
||||
$start_date = date( 'Y-m-d', strtotime( '-1 months', $current_date ) );
|
||||
$end_date = date( 'Y-m-d', $current_date );
|
||||
|
||||
$where_con = " AND DATE($wpdb->posts.post_date) >= '{$start_date}' AND DATE($wpdb->posts.post_date) <= '{$end_date}'";
|
||||
break;
|
||||
|
||||
default:
|
||||
$where_con = '';
|
||||
break;
|
||||
}
|
||||
|
||||
// Append where condition
|
||||
if( isset($where_con) ){
|
||||
$where .= $where_con;
|
||||
}
|
||||
|
||||
if(!empty($wtpsw_view_by) && $wtpsw_view_by == 'comment_count'){
|
||||
$where .= " AND $wpdb->posts.comment_count > 0";
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
|
||||
$wtpsw_model = new Wtpsw_Model();
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Public Class
|
||||
*
|
||||
* Handles the public side functionality of plugin
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Wtpsw_Public {
|
||||
|
||||
function __construct(){
|
||||
|
||||
// Ajax call to update post count
|
||||
add_action( 'wp_ajax_wtpsw_post_view_count', array($this, 'wtpsw_post_view_count') );
|
||||
add_action( 'wp_ajax_nopriv_wtpsw_post_view_count',array( $this, 'wtpsw_post_view_count') );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update views of post
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_post_view_count(){
|
||||
|
||||
$prefix = WTPSW_META_PREFIX;
|
||||
$post_id = isset($_POST['post_id']) ? $_POST['post_id'] : '';
|
||||
|
||||
if( !empty($post_id) ) {
|
||||
|
||||
// Getting existing views
|
||||
$views = get_post_meta( $post_id, $prefix.'views', true );
|
||||
$views = !empty($views) ? $views : 0;
|
||||
|
||||
// Update new views
|
||||
update_post_meta( $post_id, $prefix.'views', ($views+1) );
|
||||
|
||||
echo 'Success';
|
||||
} else {
|
||||
echo 'Error - Reference Id not found.';
|
||||
}
|
||||
die();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$wtpsw_public = new Wtpsw_Public();
|
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* Script Class
|
||||
*
|
||||
* Handles the script and style functionality of plugin
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Wtpsw_Script {
|
||||
|
||||
function __construct() {
|
||||
|
||||
// Action to add script at admin side
|
||||
add_action( 'admin_enqueue_scripts', array($this, 'wtpsw_admin_script') );
|
||||
|
||||
// Action to add style on frontend
|
||||
add_action( 'wp_enqueue_scripts', array($this, 'wtpsw_front_end_style') );
|
||||
|
||||
// Action to add script on frontend
|
||||
add_action( 'wp_enqueue_scripts', array($this, 'wtpsw_front_end_script'), 15 );
|
||||
|
||||
// Action to add admin script and style when edit with elementor at admin side
|
||||
add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'wtpsw_admin_builder_script_style' ) );
|
||||
|
||||
// Action to add admin script and style when edit with SiteOrigin at admin side
|
||||
add_action('siteorigin_panel_enqueue_admin_scripts', array( $this, 'wtpsw_admin_builder_script_style' ), 10, 2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to register admin scripts and styles
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.5
|
||||
*/
|
||||
function wtpsw_register_admin_assets() {
|
||||
|
||||
/* Styles */
|
||||
wp_register_style( 'wtpsw-admin-css', WTPSW_URL.'assets/css/wtpsw-admin.css', array(), WTPSW_VERSION );
|
||||
|
||||
/* Scripts */
|
||||
wp_register_script( 'wtpsw-admin-script', WTPSW_URL.'assets/js/wtpsw-admin.js', array('jquery'), WTPSW_VERSION, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add script at admin side
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.4
|
||||
*/
|
||||
function wtpsw_admin_script( $hook ) {
|
||||
|
||||
$this->wtpsw_register_admin_assets();
|
||||
|
||||
if( $hook == 'trending-post_page_wtpsw-help' ) {
|
||||
wp_enqueue_script( 'wtpsw-admin-script' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue front styles
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_front_end_style() {
|
||||
|
||||
// Registring and enqueing slick slider css
|
||||
if( ! wp_style_is( 'wpos-slick-style', 'registered' ) ) {
|
||||
wp_register_style( 'wpos-slick-style', WTPSW_URL.'assets/css/slick.css', null, WTPSW_VERSION );
|
||||
wp_enqueue_style('wpos-slick-style');
|
||||
}
|
||||
|
||||
// Registring slider style
|
||||
wp_register_style( 'wtpsw-public-style', WTPSW_URL.'assets/css/wtpsw-public.css', null, WTPSW_VERSION );
|
||||
wp_enqueue_style('wtpsw-public-style');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue front script
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_front_end_script() {
|
||||
|
||||
global $post;
|
||||
|
||||
// Taking post id to update post view count
|
||||
$post_id = isset($post->ID) ? $post->ID : '';
|
||||
$post_view_count = 0;
|
||||
|
||||
$supported_posts = wtpsw_get_option( 'post_types', array() ); // suppoterd post type
|
||||
|
||||
if( !empty($post_id) && !is_preview() && !empty($supported_posts) && is_singular($supported_posts) && !is_front_page() && !is_home() && !is_feed() && !is_robots() ) {
|
||||
$post_view_count = $post_id;
|
||||
}
|
||||
|
||||
// Registring slider script
|
||||
if( !wp_script_is( 'wpos-slick-jquery', 'registered' ) ) {
|
||||
wp_register_script( 'wpos-slick-jquery', WTPSW_URL.'assets/js/slick.min.js', array('jquery'), WTPSW_VERSION, true );
|
||||
}
|
||||
|
||||
// Register Elementor script
|
||||
wp_register_script( 'wtpsw-elementor-js', WTPSW_URL.'assets/js/elementor/wtpsw-elementor.js', array('jquery'), WTPSW_VERSION, true );
|
||||
|
||||
// Registering Public Script (Slider Script)
|
||||
wp_register_script( 'wtpsw-public-script', WTPSW_URL.'assets/js/wtpsw-public.js', array('jquery'), WTPSW_VERSION, true );
|
||||
wp_localize_script( 'wtpsw-public-script', 'Wtpsw', array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php', ( is_ssl() ? 'https' : 'http' ) ),
|
||||
'is_mobile' => (wp_is_mobile()) ? 1 : 0,
|
||||
'is_rtl' => (is_rtl()) ? 1 : 0,
|
||||
'post_view_count' => $post_view_count,
|
||||
|
||||
));
|
||||
wp_enqueue_script( 'wtpsw-public-script' );
|
||||
|
||||
// Enqueue Script for Elementor Preview
|
||||
if ( defined('ELEMENTOR_PLUGIN_BASE') && isset( $_GET['elementor-preview'] ) && $post->ID == (int) $_GET['elementor-preview'] ) {
|
||||
|
||||
// Dequeue public script
|
||||
wp_dequeue_script( 'wtpsw-public-script' );
|
||||
wp_enqueue_script( 'wpos-slick-jquery' );
|
||||
wp_enqueue_script( 'wtpsw-public-script' );
|
||||
wp_enqueue_script( 'wtpsw-elementor-js' );
|
||||
}
|
||||
|
||||
// Enqueue Style & Script for Beaver Builder
|
||||
if ( class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_active() ) {
|
||||
|
||||
$this->wtpsw_register_admin_assets();
|
||||
|
||||
// Dequeue admin style
|
||||
wp_enqueue_style( 'wtpsw-admin-css');
|
||||
wp_enqueue_script( 'wtpsw-admin-script' );
|
||||
|
||||
|
||||
// Dequeue public script
|
||||
wp_dequeue_script( 'wtpsw-public-script' );
|
||||
wp_enqueue_script( 'wpos-slick-jquery' );
|
||||
wp_enqueue_script( 'wtpsw-public-script' );
|
||||
}
|
||||
|
||||
// Enqueue Admin Style & Script for Divi Page Builder
|
||||
if( function_exists( 'et_core_is_fb_enabled' ) && isset( $_GET['et_fb'] ) && $_GET['et_fb'] == 1 ) {
|
||||
$this->wtpsw_register_admin_assets();
|
||||
|
||||
wp_enqueue_style( 'wtpsw-admin-css');
|
||||
}
|
||||
|
||||
// Enqueue Admin Style for Fusion Page Builder
|
||||
if( class_exists( 'FusionBuilder' ) && (( isset( $_GET['builder'] ) && $_GET['builder'] == 'true' ) ) ) {
|
||||
$this->wtpsw_register_admin_assets();
|
||||
|
||||
wp_enqueue_style( 'wtpsw-admin-css');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add script at admin side
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.5
|
||||
*/
|
||||
function wtpsw_admin_builder_script_style() {
|
||||
$this->wtpsw_register_admin_assets();
|
||||
|
||||
wp_enqueue_style( 'wtpsw-admin-css');
|
||||
wp_enqueue_script( 'wtpsw-admin-script' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$wtpsw_script = new Wtpsw_Script();
|
@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* 'wtpsw_carousel' Shortcode
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles Popuplar Post Gridbox
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.5
|
||||
*/
|
||||
function wtpsw_popular_post_carousel( $atts, $content = null ) {
|
||||
|
||||
// SiteOrigin Page Builder Gutenberg Block Tweak - Do not Display Preview
|
||||
if( isset( $_POST['action'] ) && ( $_POST['action'] == 'so_panels_layout_block_preview' || $_POST['action'] == 'so_panels_builder_content_json' ) ) {
|
||||
return '[wtpsw_carousel]';
|
||||
}
|
||||
|
||||
// Divi Frontend Builder - Do not Display Preview
|
||||
if( function_exists( 'et_core_is_fb_enabled' ) && isset( $_POST['is_fb_preview'] ) && isset( $_POST['shortcode'] ) ) {
|
||||
return '<div class="wtpsw-builder-shrt-prev">
|
||||
<div class="wtpsw-builder-shrt-title"><span>'.esc_html__('Trending Post Slider - Shortcode', 'wtpsw').'</span></div>
|
||||
wtpsw_carousel
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Fusion Builder Live Editor - Do not Display Preview
|
||||
if( class_exists( 'FusionBuilder' ) && (( isset( $_GET['builder'] ) && $_GET['builder'] == 'true' ) || ( isset( $_POST['action'] ) && $_POST['action'] == 'get_shortcode_render' )) ) {
|
||||
return '<div class="wtpsw-builder-shrt-prev">
|
||||
<div class="wtpsw-builder-shrt-title"><span>'.esc_html__('Trending Post slider - Shortcode', 'wtpsw').'</span></div>
|
||||
wtpsw_carousel
|
||||
</div>';
|
||||
}
|
||||
|
||||
global $wtpsw_options, $wtpsw_model, $wtpsw_view_by, $post;
|
||||
|
||||
// Enqueue required script
|
||||
wp_enqueue_script('wpos-slick-jquery');
|
||||
|
||||
// Shortcode attributes
|
||||
extract( shortcode_atts( array(
|
||||
'limit' => 10,
|
||||
'post_type' => 'post',
|
||||
'view_by' => 'views',
|
||||
'order' => 'DESC',
|
||||
'design' => 'design-1',
|
||||
'showdate' => 'true',
|
||||
'showauthor' => 'true',
|
||||
'showcontent' => 'false',
|
||||
'words_limit' => 40,
|
||||
'slides_to_show' => 3,
|
||||
'slides_to_scroll' => 1,
|
||||
'dots' => 'true',
|
||||
'arrows' => 'true',
|
||||
'speed' => 300,
|
||||
'autoplay' => 'true',
|
||||
'autoplayinterval' => 3000,
|
||||
'show_comment_count' => 'true',
|
||||
'hide_empty_comment_count' => 'false',
|
||||
'className' => '',
|
||||
'align' => '',
|
||||
'extra_class' => '',
|
||||
), $atts, 'wtpsw_carousel' ) );
|
||||
|
||||
$prefix = WTPSW_META_PREFIX;
|
||||
$supported_post_types = wtpsw_get_option( 'post_types', array() );
|
||||
$unique = wtpsw_get_unique();
|
||||
$limit = ( ! empty( $limit ) && is_numeric( $limit ) ) ? $limit : 10;
|
||||
$post_type = ( ! empty( $post_type ) && in_array( $post_type, $supported_post_types ) ) ? $post_type : '';
|
||||
$view_by = ! empty( $view_by ) ? $view_by : 'views';
|
||||
$order = ( strtolower($order ) == 'asc' ) ? 'ASC' : 'DESC';
|
||||
$slides_to_show = ! empty( $slides_to_show ) ? $slides_to_show : 3;
|
||||
$slides_to_scroll = ! empty( $slides_to_scroll ) ? $slides_to_scroll : 1;
|
||||
$speed = ! empty( $speed ) ? $speed : 300;
|
||||
$autoplayinterval = ! empty( $autoplayinterval ) ? $autoplayinterval : 3000;
|
||||
$hide_empty_comment_count = ( $hide_empty_comment_count == 'true' ) ? true : false;
|
||||
$align = ! empty( $align ) ? 'align'.$align : '';
|
||||
$extra_class = $extra_class .' '. $align .' '. $className;
|
||||
$extra_class = wtpsw_sanitize_html_classes( $extra_class );
|
||||
|
||||
// If no valid post type is found
|
||||
if(empty($post_type) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Slider configuration
|
||||
$slider_conf = compact('dots', 'arrows', 'autoplay', 'autoplayinterval', 'speed', 'slides_to_show', 'slides_to_scroll');
|
||||
|
||||
// Order By
|
||||
if( $view_by == 'comment' ){
|
||||
$orderby = 'comment_count';
|
||||
} elseif ( $view_by == 'views' ) {
|
||||
$orderby = 'meta_value_num';
|
||||
}
|
||||
|
||||
$wtpsw_view_by = $orderby; // Assign to global variable for query filter
|
||||
|
||||
$post_args = array(
|
||||
'post_type' => $post_type,
|
||||
'posts_per_page' => $limit,
|
||||
'order' => $order,
|
||||
'orderby' => $orderby
|
||||
);
|
||||
|
||||
if( $view_by == 'views' ) {
|
||||
$post_args['meta_key'] = $prefix.'views';
|
||||
}
|
||||
|
||||
// Wrps class variables
|
||||
$main_wrap = "wtpsw-post-carousel-{$unique}";
|
||||
$main_wrap .= " {$design}";
|
||||
$main_wrap .= " {$extra_class}";
|
||||
|
||||
// Filter to change query where condition
|
||||
add_filter( 'posts_where', array( $wtpsw_model, 'wtpsw_query_where' ) );
|
||||
|
||||
// Query to get post
|
||||
$wtpsw_posts = $wtpsw_model->wtpsw_get_posts( $post_args );
|
||||
|
||||
// Remove Filter for change query where condition
|
||||
remove_filter( 'posts_where', array( $wtpsw_model, 'wtpsw_query_where' ) );
|
||||
|
||||
ob_start();
|
||||
|
||||
if( $wtpsw_posts->have_posts() ) : ?>
|
||||
|
||||
<div id="wtpsw-carousel-<?php echo $unique; ?>" class="wtpsw-post-carousel <?php echo $main_wrap; ?>" data-conf="<?php echo htmlspecialchars(json_encode($slider_conf)); ?>">
|
||||
|
||||
<?php while ($wtpsw_posts->have_posts()) : $wtpsw_posts->the_post();
|
||||
|
||||
global $post;
|
||||
$wtpsw_post_stats = array();
|
||||
$post_id = isset($post->ID) ? $post->ID : '';
|
||||
$comment_text = wtpsw_get_comments_number( $post->ID, $hide_empty_comment_count );
|
||||
|
||||
// Design file
|
||||
include( WTPSW_DIR . '/templates/carousel/design-1.php' );
|
||||
|
||||
endwhile; ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
wp_reset_postdata(); // Reset WP Query
|
||||
$content .= ob_get_clean();
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Trending popular post carousel shortcode
|
||||
add_shortcode( 'wtpsw_carousel', 'wtpsw_popular_post_carousel' );
|
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* 'wtpsw_gridbox' Shortcode
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles Popuplar Post Gridbox
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.5
|
||||
*/
|
||||
function wtpsw_trending_post_gridbox( $atts, $content = null ) {
|
||||
|
||||
// SiteOrigin Page Builder Gutenberg Block Tweak - Do not Display Preview
|
||||
if( isset( $_POST['action'] ) && ( $_POST['action'] == 'so_panels_layout_block_preview' || $_POST['action'] == 'so_panels_builder_content_json' ) ) {
|
||||
return '[wtpsw_gridbox]';
|
||||
}
|
||||
|
||||
// Divi Frontend Builder - Do not Display Preview
|
||||
if( function_exists( 'et_core_is_fb_enabled' ) && isset( $_POST['is_fb_preview'] ) && isset( $_POST['shortcode'] ) ) {
|
||||
return '<div class="wtpsw-builder-shrt-prev">
|
||||
<div class="wtpsw-builder-shrt-title"><span>'.esc_html__('Trending Post Slider - Shortcode', 'wtpsw').'</span></div>
|
||||
wtpsw_gridbox
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Fusion Builder Live Editor - Do not Display Preview
|
||||
if( class_exists( 'FusionBuilder' ) && (( isset( $_GET['builder'] ) && $_GET['builder'] == 'true' ) || ( isset( $_POST['action'] ) && $_POST['action'] == 'get_shortcode_render' )) ) {
|
||||
return '<div class="wtpsw-builder-shrt-prev">
|
||||
<div class="wtpsw-builder-shrt-title"><span>'.esc_html__('Trending Post slider - Shortcode', 'wtpsw').'</span></div>
|
||||
wtpsw_gridbox
|
||||
</div>';
|
||||
}
|
||||
|
||||
global $wtpsw_options, $wtpsw_model, $wtpsw_view_by, $post;
|
||||
|
||||
// Enqueue required script
|
||||
wp_enqueue_script('wpos-slick-jquery');
|
||||
|
||||
// Shortcode attributes
|
||||
extract( shortcode_atts( array(
|
||||
'limit' => 5,
|
||||
'post_type' => 'post',
|
||||
'view_by' => 'views',
|
||||
'order' => 'DESC',
|
||||
'design' => 'design-1',
|
||||
'showdate' => 'true',
|
||||
'showauthor' => 'true',
|
||||
'showcontent' => 'false',
|
||||
'words_limit' => 40,
|
||||
'show_comment_count' => 'true',
|
||||
'hide_empty_comment_count' => 'false',
|
||||
'className' => '',
|
||||
'align' => '',
|
||||
'extra_class' => '',
|
||||
), $atts, 'wtpsw_gridbox' ) );
|
||||
|
||||
$prefix = WTPSW_META_PREFIX;
|
||||
$supported_post_types = wtpsw_get_option( 'post_types', array() );
|
||||
$post_type = ( ! empty( $post_type ) && in_array( $post_type, $supported_post_types ) ) ? $post_type : '';
|
||||
$limit = ( ! empty( $limit ) && is_numeric( $limit ) ) ? $limit : 10;
|
||||
$view_by = ! empty( $view_by ) ? $view_by : 'views';
|
||||
$order = ( strtolower($order ) == 'asc' ) ? 'ASC' : 'DESC';
|
||||
$hide_empty_comment_count = ( $hide_empty_comment_count == 'true' ) ? true : false;
|
||||
$align = ! empty( $align ) ? 'align'.$align : '';
|
||||
$extra_class = $extra_class .' '. $align .' '. $className;
|
||||
$extra_class = wtpsw_sanitize_html_classes( $extra_class );
|
||||
|
||||
// If no valid post type is found
|
||||
if( empty($post_type) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Count variables
|
||||
$wtpsw_count = 1;
|
||||
|
||||
// Order By
|
||||
if( $view_by == 'comment' ) {
|
||||
$orderby = 'comment_count';
|
||||
} elseif ( $view_by == 'views' ) {
|
||||
$orderby = 'meta_value_num';
|
||||
}
|
||||
|
||||
$wtpsw_view_by = $orderby; // Assign to global variable for query filter
|
||||
|
||||
$post_args = array(
|
||||
'post_type' => $post_type,
|
||||
'posts_per_page' => $limit,
|
||||
'order' => $order,
|
||||
'orderby' => $orderby
|
||||
);
|
||||
|
||||
if( $view_by == 'views' ) {
|
||||
$post_args['meta_key'] = $prefix.'views';
|
||||
}
|
||||
|
||||
// Wrps class variables
|
||||
$main_wrap = "{$design}";
|
||||
$main_wrap .= " {$extra_class}";
|
||||
|
||||
// Filter to change query where condition
|
||||
add_filter( 'posts_where', array( $wtpsw_model, 'wtpsw_query_where' ) );
|
||||
|
||||
// Query to get post
|
||||
$wtpsw_posts = $wtpsw_model->wtpsw_get_posts( $post_args );
|
||||
|
||||
// Remove Filter for change query where condition
|
||||
remove_filter( 'posts_where', array( $wtpsw_model, 'wtpsw_query_where' ) );
|
||||
|
||||
ob_start();
|
||||
|
||||
if( $wtpsw_posts->have_posts() ) : ?>
|
||||
|
||||
<div class="wtpsw-post-grid <?php echo $main_wrap; ?> wtpsw-clearfix">
|
||||
|
||||
<?php while ($wtpsw_posts->have_posts()) : $wtpsw_posts->the_post();
|
||||
|
||||
global $post;
|
||||
$wtpsw_post_stats = array();
|
||||
$post_id = isset($post->ID) ? $post->ID : '';
|
||||
$comment_text = wtpsw_get_comments_number( $post->ID, $hide_empty_comment_count );
|
||||
|
||||
// Design file
|
||||
include( WTPSW_DIR . '/templates/grid-box/design-1.php' );
|
||||
|
||||
$wtpsw_count++;
|
||||
endwhile; ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
wp_reset_postdata();
|
||||
$content .= ob_get_clean();
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Trending popular post gridbox shortcode
|
||||
add_shortcode( 'wtpsw_gridbox', 'wtpsw_trending_post_gridbox' );
|
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* 'wtpsw_popular_post' Shortcode
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles Popuplar Post Gridbox
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.5
|
||||
*/
|
||||
function wtpsw_trending_post_slider( $atts, $content = null ) {
|
||||
|
||||
// SiteOrigin Page Builder Gutenberg Block Tweak - Do not Display Preview
|
||||
if( isset( $_POST['action'] ) && ( $_POST['action'] == 'so_panels_layout_block_preview' || $_POST['action'] == 'so_panels_builder_content_json' ) ) {
|
||||
return '[wtpsw_popular_post]';
|
||||
}
|
||||
|
||||
// Divi Frontend Builder - Do not Display Preview
|
||||
if( function_exists( 'et_core_is_fb_enabled' ) && isset( $_POST['is_fb_preview'] ) && isset( $_POST['shortcode'] ) ) {
|
||||
return '<div class="wtpsw-builder-shrt-prev">
|
||||
<div class="wtpsw-builder-shrt-title"><span>'.esc_html__('Trending Post Slider - Shortcode', 'wtpsw').'</span></div>
|
||||
wtpsw_popular_post
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Fusion Builder Live Editor - Do not Display Preview
|
||||
if( class_exists( 'FusionBuilder' ) && (( isset( $_GET['builder'] ) && $_GET['builder'] == 'true' ) || ( isset( $_POST['action'] ) && $_POST['action'] == 'get_shortcode_render' )) ) {
|
||||
return '<div class="wtpsw-builder-shrt-prev">
|
||||
<div class="wtpsw-builder-shrt-title"><span>'.esc_html__('Trending Post slider - Shortcode', 'wtpsw').'</span></div>
|
||||
wtpsw_popular_post
|
||||
</div>';
|
||||
}
|
||||
|
||||
global $wtpsw_options, $wtpsw_model, $wtpsw_view_by, $post;
|
||||
|
||||
// Enqueue required script
|
||||
wp_enqueue_script('wpos-slick-jquery');
|
||||
|
||||
// Shortcode attributes
|
||||
extract( shortcode_atts( array(
|
||||
'limit' => 10,
|
||||
'post_type' => 'post',
|
||||
'view_by' => 'views',
|
||||
'order' => 'DESC',
|
||||
'design' => 'design-1',
|
||||
'showdate' => 'true',
|
||||
'showauthor' => 'true',
|
||||
'showcontent' => 'true',
|
||||
'words_limit' => 40,
|
||||
'dots' => 'true',
|
||||
'arrows' => 'true',
|
||||
'speed' => 300,
|
||||
'autoplay' => 'true',
|
||||
'autoplayinterval' => 3000,
|
||||
'show_comment_count' => 'true',
|
||||
'hide_empty_comment_count' => 'false',
|
||||
'className' => '',
|
||||
'align' => '',
|
||||
'extra_class' => '',
|
||||
), $atts, 'wtpsw_popular_post' ) );
|
||||
|
||||
$prefix = WTPSW_META_PREFIX;
|
||||
$unique = wtpsw_get_unique();
|
||||
$supported_post_types = wtpsw_get_option( 'post_types', array() );
|
||||
$post_type = ( ! empty( $post_type ) && in_array( $post_type, $supported_post_types ) ) ? $post_type : '';
|
||||
$limit = ( ! empty( $limit ) && is_numeric( $limit ) ) ? $limit : 10;
|
||||
$view_by = ! empty( $view_by ) ? $view_by : 'views';
|
||||
$speed = ! empty( $speed ) ? $speed : 300;
|
||||
$autoplayinterval = ! empty( $autoplayinterval ) ? $autoplayinterval : 3000;
|
||||
$order = ( strtolower($order ) == 'asc' ) ? 'ASC' : 'DESC';
|
||||
$hide_empty_comment_count = ( $hide_empty_comment_count == 'true' ) ? true : false;
|
||||
$align = ! empty( $align ) ? 'align'.$align : '';
|
||||
$extra_class = $extra_class .' '. $align .' '. $className;
|
||||
$extra_class = wtpsw_sanitize_html_classes( $extra_class );
|
||||
|
||||
// Return if no valid post type
|
||||
if( empty( $post_type ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Slider configuration
|
||||
$slider_conf = compact('dots', 'arrows', 'autoplay', 'autoplayinterval', 'speed');
|
||||
|
||||
// Order By
|
||||
if( $view_by == 'comment' ) {
|
||||
$orderby = 'comment_count';
|
||||
} elseif ( $view_by == 'views' ) {
|
||||
$orderby = 'meta_value_num';
|
||||
}
|
||||
|
||||
$wtpsw_view_by = $orderby; // Assign to global variable for query filter
|
||||
|
||||
$post_args = array(
|
||||
'post_type' => $post_type,
|
||||
'posts_per_page' => $limit,
|
||||
'order' => $order,
|
||||
'orderby' => $orderby
|
||||
);
|
||||
|
||||
if( $view_by == 'views' ) {
|
||||
$post_args['meta_key'] = $prefix.'views';
|
||||
}
|
||||
|
||||
// Wrps class variables
|
||||
$main_wrap = "wtpsw-post-slider-{$unique}";
|
||||
$main_wrap .= " {$design}";
|
||||
$main_wrap .= " {$extra_class}";
|
||||
|
||||
// Filter to change query where condition
|
||||
add_filter( 'posts_where', array( $wtpsw_model, 'wtpsw_query_where' ) );
|
||||
|
||||
// Query to get post
|
||||
$wtpsw_posts = $wtpsw_model->wtpsw_get_posts( $post_args );
|
||||
|
||||
// Remove Filter for change query where condition
|
||||
remove_filter( 'posts_where', array( $wtpsw_model, 'wtpsw_query_where' ) );
|
||||
|
||||
ob_start();
|
||||
|
||||
if( $wtpsw_posts->have_posts() ) : ?>
|
||||
|
||||
<div id="wtpsw-slider-<?php echo $unique; ?>" class="wtpsw-post-slider <?php echo $main_wrap; ?>" data-conf="<?php echo htmlspecialchars(json_encode($slider_conf)); ?>">
|
||||
|
||||
<?php while ($wtpsw_posts->have_posts()) : $wtpsw_posts->the_post();
|
||||
|
||||
global $post;
|
||||
$wtpsw_post_stats = array();
|
||||
$post_id = isset($post->ID) ? $post->ID : '';
|
||||
$comment_text = wtpsw_get_comments_number( $post->ID, $hide_empty_comment_count );
|
||||
|
||||
// Design file
|
||||
include( WTPSW_DIR . "/templates/slider/design-1.php" );
|
||||
|
||||
endwhile; ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
endif;
|
||||
wp_reset_postdata(); // Reset WP Query
|
||||
$content .= ob_get_clean();
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Trending popular post Slider shortcode
|
||||
add_shortcode( 'wtpsw_popular_post', 'wtpsw_trending_post_slider' );
|
@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
add_action( 'widgets_init', 'wtpsw_post_list_widget' );
|
||||
|
||||
/**
|
||||
* Register trending post vertical slider widget
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_post_list_widget() {
|
||||
register_widget( 'Wtpsw_Post_List_Widget' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Vertical Scrolling Post Widget Class
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' )) exit;
|
||||
|
||||
class Wtpsw_Post_List_Widget extends WP_Widget {
|
||||
|
||||
var $model, $defaults;
|
||||
|
||||
function __construct() {
|
||||
|
||||
global $wtpsw_model;
|
||||
$this->model = $wtpsw_model;
|
||||
|
||||
// Widget settings
|
||||
$widget_ops = array( 'classname' => 'wtpsw_post_list_widget', 'description' => __( 'Display most popular trending post on your blog.', 'wtpsw' ) );
|
||||
|
||||
// Create the widget
|
||||
parent::__construct( 'wtpsw-post-list-widget', __( 'WPOS - Trending Posts', 'wtpsw' ), $widget_ops );
|
||||
|
||||
$this->defaults = array(
|
||||
'title' => __( 'Trending Posts', 'wtpsw' ),
|
||||
'limit' => 5,
|
||||
'post_type' => 'post',
|
||||
'show_content' => 0,
|
||||
'show_thumb' => 1,
|
||||
'show_author' => 1,
|
||||
'show_date' => 1,
|
||||
'order' => 'DESC',
|
||||
'view_by' => 'views',
|
||||
'content_length' => 20,
|
||||
'show_comment_count' => 1,
|
||||
'hide_empty_comment_count' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the widget control options
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function update( $new_instance, $old_instance ) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
// Input fields
|
||||
$instance['post_type'] = $new_instance['post_type'];
|
||||
$instance['view_by'] = $new_instance['view_by'];
|
||||
$instance['title'] = strip_tags( $new_instance['title'] );
|
||||
$instance['limit'] = ( empty($new_instance['limit'] ) || ( $new_instance['limit'] < -1 ) ) ? 5 : $new_instance['limit'];
|
||||
$instance['order'] = ( isset( $new_instance['order'] ) && $new_instance['order'] == 'ASC' ) ? 'ASC' : 'DESC';
|
||||
$instance['content_length'] = ! empty( $new_instance['content_length'] ) ? $new_instance['content_length'] : 20;
|
||||
$instance['show_author'] = ! empty( $new_instance['show_author'] ) ? 1 : 0;
|
||||
$instance['show_comment_count'] = ! empty( $new_instance['show_comment_count'] ) ? 1 : 0;
|
||||
$instance['show_content'] = ! empty( $new_instance['show_content'] ) ? 1 : 0;
|
||||
$instance['show_thumb'] = ! empty( $new_instance['show_thumb'] ) ? 1 : 0;
|
||||
$instance['show_date'] = ! empty( $new_instance['show_date'] ) ? 1 : 0;
|
||||
$instance['hide_empty_comment_count'] = ! empty( $new_instance['hide_empty_comment_count'] ) ? 1 : 0;
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the widget form in widget area
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function form( $instance ) {
|
||||
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
||||
$post_types = wtpsw_get_post_types();
|
||||
$support_post_types = wtpsw_get_option( 'post_types', array() );
|
||||
$sel_post_type = ( ! empty( $instance['post_type'] ) && in_array( $instance['post_type'], $support_post_types ) ) ? $instance['post_type'] : '';
|
||||
?>
|
||||
|
||||
<div class="wtpsw-widget-wrap">
|
||||
|
||||
<!-- Title Field -->
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title', 'wtpsw'); ?>:</label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" />
|
||||
</p>
|
||||
|
||||
<!-- Post type -->
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e( 'Post Type', 'wtpsw' ); ?>:</label>
|
||||
<select class="widefat ftpp-reg-post-types" id="<?php echo $this->get_field_id('post_type'); ?>" name="<?php echo $this->get_field_name('post_type'); ?>" >
|
||||
<option value="" selected ><?php _e( 'Select Post Type', 'wtpsw'); ?></option>
|
||||
<?php
|
||||
if( !empty($post_types) ) {
|
||||
foreach ($post_types as $post_key => $post_value) {
|
||||
if(in_array($post_key, $support_post_types)) {
|
||||
echo '<option value="'.$post_key.'" '.selected($post_key, $instance['post_type']).'>'.$post_value.'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- View By Field -->
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'view_by' ); ?>"><?php _e( 'Post List By', 'wtpsw'); ?>:</label>
|
||||
<select class="widefat" id="<?php echo $this->get_field_id( 'view_by' ); ?>" name="<?php echo $this->get_field_name( 'view_by' ); ?>">
|
||||
<option value="views" <?php selected( $instance['view_by'], 'views' ); ?> ><?php _e('Total Views', 'wtpsw') ?></option>
|
||||
<option value="comment" <?php selected( $instance['view_by'], 'comment' ); ?>><?php _e('Comments Count', 'wtpsw'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Number of Items Field -->
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e( 'Number of Items', 'wtpsw'); ?>:</label>
|
||||
<input class="widefat" min="-1" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo $instance['limit']; ?>" />
|
||||
</p>
|
||||
|
||||
<!-- Order Field -->
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e( 'Order', 'wtpsw'); ?>:</label>
|
||||
<select class="widefat" id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>">
|
||||
<option value="ASC" <?php selected( $instance['order'], 'ASC' ); ?> ><?php _e('ASC', 'wtpsw') ?></option>
|
||||
<option value="DESC" <?php selected( $instance['order'], 'DESC' ); ?>><?php _e('DESC', 'wtpsw'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<!-- Show Content Field -->
|
||||
<p>
|
||||
<input type="checkbox" value="1" id="<?php echo $this->get_field_id( 'show_content' ); ?>" name="<?php echo $this->get_field_name( 'show_content' ); ?>" <?php checked( $instance['show_content'], 1 ); ?> />
|
||||
<label for="<?php echo $this->get_field_id( 'show_content' ); ?>"><?php _e( 'Display Short Content', 'wtpsw' ); ?></label><br/>
|
||||
<span class="description"><em><?php _e('If your post has excerpt then it will take it else post content will be taken.', 'wtpsw'); ?></em></span>
|
||||
</p>
|
||||
|
||||
<!-- Show Post Content Word Limit -->
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'content_length' ); ?>"><?php _e( 'Post Content Length', 'wtpsw'); ?>:</label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id( 'content_length' ); ?>" name="<?php echo $this->get_field_name( 'content_length' ); ?>" type="number" min="1" value="<?php echo $instance['content_length']; ?>" />
|
||||
<span class="description"><em><?php _e('Enter number of words to display in post content.', 'wtpsw'); ?></em></span>
|
||||
</p>
|
||||
|
||||
<!-- Show Thumbnail Field -->
|
||||
<p>
|
||||
<input type="checkbox" value="1" id="<?php echo $this->get_field_id( 'show_thumb' ); ?>" name="<?php echo $this->get_field_name( 'show_thumb' ); ?>" <?php checked( $instance['show_thumb'], 1 ); ?> />
|
||||
<label for="<?php echo $this->get_field_id( 'show_thumb' ); ?>"><?php _e( 'Show Thumbnail', 'wtpsw'); ?></label>
|
||||
</p>
|
||||
|
||||
<!-- Show Author Field -->
|
||||
<p>
|
||||
<input type="checkbox" value="1" id="<?php echo $this->get_field_id( 'show_author' ); ?>" name="<?php echo $this->get_field_name( 'show_author' ); ?>" <?php checked( $instance['show_author'], 1 ); ?> />
|
||||
<label for="<?php echo $this->get_field_id( 'show_author' ); ?>"><?php _e( 'Show Author', 'wtpsw'); ?></label>
|
||||
</p>
|
||||
|
||||
<!-- Show Date Field -->
|
||||
<p>
|
||||
<input type="checkbox" value="1" id="<?php echo $this->get_field_id( 'show_date' ); ?>" name="<?php echo $this->get_field_name( 'show_date' ); ?>" <?php checked( $instance['show_date'], 1 ); ?> />
|
||||
<label for="<?php echo $this->get_field_id( 'show_date' ); ?>"><?php _e( 'Show Date', 'wtpsw'); ?></label>
|
||||
</p>
|
||||
|
||||
<!-- Show Comment Field -->
|
||||
<p>
|
||||
<input type="checkbox" value="1" id="<?php echo $this->get_field_id( 'show_comment_count' ); ?>" name="<?php echo $this->get_field_name( 'show_comment_count' ); ?>" <?php checked( $instance['show_comment_count'], 1 ); ?> />
|
||||
<label for="<?php echo $this->get_field_id( 'show_comment_count' ); ?>"><?php _e( 'Show Comment Count', 'wtpsw'); ?></label>
|
||||
</p>
|
||||
|
||||
<!-- Show Comment Field -->
|
||||
<p>
|
||||
<input type="checkbox" value="1" id="<?php echo $this->get_field_id( 'hide_empty_comment_count' ); ?>" name="<?php echo $this->get_field_name( 'hide_empty_comment_count' ); ?>" <?php checked( $instance['hide_empty_comment_count'], 1 ); ?> />
|
||||
<label for="<?php echo $this->get_field_id( 'hide_empty_comment_count' ); ?>"><?php _e( 'Hide Empty Comment Count', 'wtpsw'); ?></label><br/>
|
||||
<span class="description"><em><?php _e('Hide comment count if it is empty.', 'wtpsw'); ?></em></span>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the content of the widget
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function widget( $args, $instance ) {
|
||||
|
||||
// SiteOrigin Page Builder Gutenberg Block Tweak - Do not Display Preview
|
||||
if( isset( $_POST['action'] ) && ( $_POST['action'] == 'so_panels_layout_block_preview' || $_POST['action'] == 'so_panels_builder_content_json' ) ) {
|
||||
echo "<div class='wtpsw-builder-shrt-prev'><div class='wtpsw-builder-shrt-title'><span>".esc_html__('Trending Post List - Widget', 'wtpsw')."</span></div>WPOS - Trending Post List</div>";
|
||||
return;
|
||||
}
|
||||
|
||||
global $wtpsw_options, $wtpsw_view_by;
|
||||
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
||||
extract( $args );
|
||||
|
||||
$prefix = WTPSW_META_PREFIX;
|
||||
$support_post_types = wtpsw_get_option('post_types', array());
|
||||
$title = $instance['title'];
|
||||
$limit = $instance['limit'];
|
||||
$order = $instance['order'];
|
||||
$view_by = $instance['view_by'];
|
||||
$content_length = $instance['content_length'];
|
||||
$post_type = ( ! empty( $instance['post_type'] ) && in_array( $instance['post_type'], $support_post_types ) ) ? $instance['post_type'] : '';
|
||||
$post_type = ( ! empty( $instance['post_type'] ) && in_array( $instance['post_type'], $support_post_types ) ) ? $instance['post_type'] : '';
|
||||
$show_date = ! empty( $instance['show_date'] ) ? true : false;
|
||||
$show_author = ! empty( $instance['show_author'] ) ? true : false;
|
||||
$show_comment_count = ! empty( $instance['show_comment_count'] ) ? true : false;
|
||||
$show_thumb = ! empty( $instance['show_thumb'] ) ? true : false;
|
||||
$show_content = ! empty( $instance['show_content'] ) ? true : false;
|
||||
$hide_empty_comment_count = ! empty( $instance['hide_empty_comment_count'] ) ? true : false;
|
||||
|
||||
// If no valid post type is found
|
||||
if( empty( $post_type ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Order By
|
||||
if( $view_by == 'comment' ) {
|
||||
$orderby = 'comment_count';
|
||||
} elseif ( $view_by == 'views' ) {
|
||||
$orderby = 'meta_value_num';
|
||||
}
|
||||
|
||||
$wtpsw_view_by = $orderby; // Assign to global variable for query filter
|
||||
|
||||
$post_args = array(
|
||||
'post_type' => $post_type,
|
||||
'posts_per_page' => $limit,
|
||||
'order' => $order,
|
||||
'orderby' => $orderby
|
||||
);
|
||||
|
||||
if( $view_by == 'views' ) {
|
||||
$post_args['meta_key'] = $prefix.'views';
|
||||
}
|
||||
|
||||
// Filter to change query where condition
|
||||
add_filter( 'posts_where', array($this->model, 'wtpsw_query_where') );
|
||||
|
||||
// Query to get post
|
||||
$wtpsw_posts = $this->model->wtpsw_get_posts( $post_args );
|
||||
|
||||
// Remove Filter for change query where condition
|
||||
remove_filter( 'posts_where', array($this->model, 'wtpsw_query_where') );
|
||||
|
||||
echo $before_widget;
|
||||
|
||||
if ( $title ) {
|
||||
echo $before_title . $title . $after_title;
|
||||
}
|
||||
|
||||
if( $wtpsw_posts->have_posts() ) : ?>
|
||||
<div class="wtpsw-post-items">
|
||||
<ul>
|
||||
<?php while ($wtpsw_posts->have_posts()) : $wtpsw_posts->the_post();
|
||||
|
||||
global $post;
|
||||
$wtpsw_stats = array(); // Need to flush
|
||||
$comment_text = wtpsw_get_comments_number( $post->ID, $hide_empty_comment_count );
|
||||
|
||||
// Design file
|
||||
include( WTPSW_DIR . '/templates/wtpsw-post-lists.php' );
|
||||
|
||||
endwhile; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
wp_reset_postdata(); // Reset WP Query
|
||||
echo $after_widget;
|
||||
}
|
||||
}
|
@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/**
|
||||
* Functions File
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Update default settings
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_default_settings(){
|
||||
|
||||
global $wtpsw_options;
|
||||
|
||||
$wtpsw_options = array(
|
||||
'post_range' => '',
|
||||
'post_types' => array( 'post' ),
|
||||
);
|
||||
|
||||
$default_options = apply_filters('wtpsw_options_default_values', $wtpsw_options );
|
||||
|
||||
// Update default options
|
||||
update_option( 'wtpsw_options', $default_options );
|
||||
|
||||
// Overwrite global variable when option is update
|
||||
$wtpsw_options = wtpsw_get_settings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Settings From Option Page
|
||||
*
|
||||
* Handles to return all settings value
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_get_settings() {
|
||||
|
||||
$options = get_option('wtpsw_options');
|
||||
$settings = is_array($options) ? $options : array();
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option
|
||||
* Looks to see if the specified setting exists, returns default if not
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0
|
||||
*/
|
||||
function wtpsw_get_option( $key = '', $default = false ) {
|
||||
global $wtpsw_options;
|
||||
|
||||
$value = ! empty( $wtpsw_options[ $key ] ) ? $wtpsw_options[ $key ] : $default;
|
||||
$value = apply_filters( 'wtpsw_get_option', $value, $key, $default );
|
||||
return apply_filters( 'wtpsw_get_option_' . $key, $value, $key, $default );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize Multiple HTML class
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.5
|
||||
*/
|
||||
function wtpsw_sanitize_html_classes($classes, $sep = " ") {
|
||||
$return = "";
|
||||
|
||||
if( ! is_array( $classes ) ) {
|
||||
$classes = explode($sep, $classes);
|
||||
}
|
||||
|
||||
if( ! empty( $classes ) ) {
|
||||
foreach($classes as $class){
|
||||
$return .= sanitize_html_class($class) . " ";
|
||||
}
|
||||
$return = trim( $return );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Object To Array
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_object_to_array($result) {
|
||||
|
||||
$array = array();
|
||||
|
||||
foreach ($result as $key=>$value) {
|
||||
if (is_object($value)) {
|
||||
$array[$key] = wtpsw_object_to_array($value);
|
||||
} else {
|
||||
$array[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to unique number value
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_get_unique() {
|
||||
static $unique = 0;
|
||||
$unique++;
|
||||
|
||||
// For Elementor & Beaver Builder
|
||||
if( ( defined('ELEMENTOR_PLUGIN_BASE') && isset( $_POST['action'] ) && $_POST['action'] == 'elementor_ajax' )
|
||||
|| ( class_exists('FLBuilderModel') && ! empty( $_POST['fl_builder_data']['action'] ) )
|
||||
|| ( function_exists('vc_is_inline') && vc_is_inline() ) ) {
|
||||
$unique = current_time('timestamp') . '-' . rand();
|
||||
}
|
||||
|
||||
return $unique;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get post excerpt
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_get_post_excerpt( $post_id = null, $content = '', $word_length = '55', $more = '...' ) {
|
||||
|
||||
$word_length = !empty($word_length) ? $word_length : '55';
|
||||
|
||||
// If post id is passed
|
||||
if( !empty($post_id) ) {
|
||||
if (has_excerpt($post_id)) {
|
||||
$content = get_the_excerpt();
|
||||
} else {
|
||||
$content = !empty($content) ? $content : get_the_content();
|
||||
}
|
||||
}
|
||||
|
||||
if( !empty($content) ) {
|
||||
$content = strip_shortcodes( $content ); // Strip shortcodes
|
||||
$content = wp_trim_words( $content, $word_length, $more );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get registered post types
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_get_post_types( $args = array() ) {
|
||||
|
||||
// Taking defaults
|
||||
$all_post_types = array();
|
||||
$post_types = array();
|
||||
|
||||
$args = array(
|
||||
'public' => !empty($args['public']) ? $args['public'] : 'true'
|
||||
);
|
||||
|
||||
$all_post_types = get_post_types( $args, 'object' );
|
||||
$exclude_post = array('attachment');
|
||||
|
||||
foreach ($all_post_types as $post_type_key => $post_data) {
|
||||
if( !in_array( $post_type_key, $exclude_post) ) {
|
||||
$post_types[$post_type_key] = !empty($post_data->label) ? $post_data->label : $post_type_key;
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters('wtpsw_get_post_types', $post_types );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get comment count text
|
||||
*
|
||||
* @package WP Trending Post Slider and Widget
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function wtpsw_get_comments_number( $post_id = '', $hide_empty = false ) {
|
||||
|
||||
$comment_text = '';
|
||||
|
||||
if( !empty($post_id) ) {
|
||||
|
||||
$comment_number = get_comments_number( $post_id );
|
||||
|
||||
if ( $comment_number == 0 && empty($hide_empty) ) {
|
||||
$comment_text = __('0 Comments', 'wtpsw');
|
||||
} elseif ( $comment_number > 1 ) {
|
||||
$comment_text = $comment_number . __(' Comments', 'wtpsw');
|
||||
} elseif ( $comment_number == 1 ) {
|
||||
$comment_text = __('1 Comment', 'wtpsw');
|
||||
}
|
||||
}
|
||||
|
||||
return $comment_text;
|
||||
}
|
Reference in New Issue
Block a user