| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: BNE Testimonials |
| 4 |
* Version: 2.0.8.2 |
| 5 |
* Description: Display testimonials on any page or widget area as list or slider. Upgrade to PRO for additional layouts, themes, API, 5-star ratings and schema markup. |
| 6 |
* Author: Kerry Kline |
| 7 |
* Author URI: https://www.bnecreative.com |
| 8 |
* Requires at least: 5.0 |
| 9 |
* Text Domain: bne-testimonials |
| 10 |
* License: GPL2 |
| 11 |
|
| 12 |
Copyright (C) 2013-2020 BNE Creative |
| 13 |
|
| 14 |
This program is free software; you can redistribute it and/or modify |
| 15 |
it under the terms of the GNU General Public License version 2, |
| 16 |
as published by the Free Software Foundation. |
| 17 |
|
| 18 |
You may NOT assume that you can use any other version of the GPL. |
| 19 |
|
| 20 |
This program is distributed in the hope that it will be useful, |
| 21 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 |
GNU General Public License for more details. |
| 24 |
|
| 25 |
The license for this software can likely be found here: |
| 26 |
http://www.gnu.org/licenses/gpl-2.0.html |
| 27 |
|
| 28 |
*/ |
| 29 |
|
| 30 |
|
| 31 |
// Exit if accessed directly |
| 32 |
if ( !defined('ABSPATH')) exit; |
| 33 |
|
| 34 |
|
| 35 |
// INIT Class |
| 36 |
class BNE_Testimonials { |
| 37 |
|
| 38 |
|
| 39 |
/* |
| 40 |
* Constructor |
| 41 |
* |
| 42 |
* @since v2.0 |
| 43 |
* |
| 44 |
*/ |
| 45 |
function __construct() { |
| 46 |
|
| 47 |
// Set Constants |
| 48 |
define( 'BNE_TESTIMONIALS_VERSION', '2.0.8.2' ); |
| 49 |
define( 'BNE_TESTIMONIALS_DIR', dirname( __FILE__ ) ); |
| 50 |
define( 'BNE_TESTIMONIALS_URI', plugins_url( '', __FILE__ ) ); |
| 51 |
define( 'BNE_TESTIMONIALS_BASENAME', plugin_basename( __FILE__ ) ); |
| 52 |
define( 'BNE_TESTIMONIALS_TEXTDOMAIN', 'bne-testimonials' ); |
| 53 |
|
| 54 |
// Textdomain |
| 55 |
add_action( 'plugins_loaded', array( $this, 'text_domain' ) ); |
| 56 |
|
| 57 |
// Setup Includes / Files |
| 58 |
add_action( 'after_setup_theme', array( $this, 'setup' ) ); |
| 59 |
|
| 60 |
// Scripts |
| 61 |
add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) ); |
| 62 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 11, 1 ); |
| 63 |
|
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
/* |
| 70 |
* Textdomain for Localization |
| 71 |
* |
| 72 |
* @since v2.0 |
| 73 |
* |
| 74 |
*/ |
| 75 |
function text_domain() { |
| 76 |
load_plugin_textdomain( BNE_TESTIMONIALS_TEXTDOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
/* |
| 83 |
* Plugin Setup |
| 84 |
* |
| 85 |
* @since v2.0.2 |
| 86 |
* |
| 87 |
*/ |
| 88 |
function setup() { |
| 89 |
|
| 90 |
// Admin Only Pages |
| 91 |
if( is_admin() ) { |
| 92 |
|
| 93 |
// Libraries |
| 94 |
include_once( BNE_TESTIMONIALS_DIR . '/includes/lib/cmb2/init.php' ); |
| 95 |
|
| 96 |
// Admin Help Page |
| 97 |
include_once( BNE_TESTIMONIALS_DIR . '/includes/help/help.php' ); |
| 98 |
} |
| 99 |
|
| 100 |
// Locals |
| 101 |
include_once( BNE_TESTIMONIALS_DIR . '/includes/locals.php' ); |
| 102 |
|
| 103 |
// CPT |
| 104 |
include_once( BNE_TESTIMONIALS_DIR . '/includes/lib/bne_cpt-class.php' ); |
| 105 |
include_once( BNE_TESTIMONIALS_DIR . '/includes/cpt-main.php' ); |
| 106 |
|
| 107 |
// Shortcodes |
| 108 |
include_once( BNE_TESTIMONIALS_DIR . '/includes/shortcode-display.php' ); |
| 109 |
|
| 110 |
|
| 111 |
/* |
| 112 |
* Thumbnail Support |
| 113 |
* |
| 114 |
* Because some themes will selectively choose what post types |
| 115 |
* can use post-thumbnails, we will first remove support to |
| 116 |
* basically reset the option, then we will add it back. |
| 117 |
* |
| 118 |
* This may seem link backwards thinking, but works. |
| 119 |
* |
| 120 |
*/ |
| 121 |
remove_theme_support( 'post-thumbnails' ); |
| 122 |
if( !current_theme_supports( 'post-thumbnails' ) ) { |
| 123 |
add_theme_support( 'post-thumbnails' ); |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
/* |
| 128 |
* v1.x legacy Shortcodes and Widgets |
| 129 |
* |
| 130 |
* Prior to v2.0, Testimonials used a customizable filter set |
| 131 |
* to output the data. This allowed devs to re-arrange and customize |
| 132 |
* how the testimonials are displayed. With v2.0+ we have removed all |
| 133 |
* of this in favor of matching to the pro version (which uses themes/layouts). |
| 134 |
* |
| 135 |
* To prevent confusion and disruption of customizations, we have moved these functions here |
| 136 |
* and can only be called using the legacy shortcode variants and widgets. |
| 137 |
* |
| 138 |
* Shortcodes using this structure: |
| 139 |
* [bne_testimonials_list] |
| 140 |
* [bne_testimonials_slider] |
| 141 |
* |
| 142 |
*/ |
| 143 |
|
| 144 |
// Planned Migration Step 2 of 3 |
| 145 |
include_once( BNE_TESTIMONIALS_DIR . '/includes/legacy/migrate.php' ); |
| 146 |
|
| 147 |
//include_once( BNE_TESTIMONIALS_DIR . '/includes/legacy/testimonial-output.php' ); |
| 148 |
//include_once( BNE_TESTIMONIALS_DIR . '/includes/legacy/shortcode-list.php' ); |
| 149 |
//include_once( BNE_TESTIMONIALS_DIR . '/includes/legacy/shortcode-slider.php' ); |
| 150 |
|
| 151 |
include_once( BNE_TESTIMONIALS_DIR . '/includes/legacy/widget-list.php' ); |
| 152 |
include_once( BNE_TESTIMONIALS_DIR . '/includes/legacy/widget-slider.php' ); |
| 153 |
|
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
/* |
| 158 |
* Register frontend CSS and JS |
| 159 |
* |
| 160 |
* @since v1.0 |
| 161 |
* @updated v2.0 |
| 162 |
* |
| 163 |
*/ |
| 164 |
function frontend_scripts() { |
| 165 |
|
| 166 |
$min = ( defined('WP_DEBUG') && true === WP_DEBUG ) ? '' : '.min'; |
| 167 |
|
| 168 |
// CSS |
| 169 |
wp_register_style( 'bne-testimonials-css', BNE_TESTIMONIALS_URI . '/assets/css/bne-testimonials'.$min.'.css', '', BNE_TESTIMONIALS_VERSION, 'all' ); |
| 170 |
|
| 171 |
// Check if we're on a BNE WordPress Theme... |
| 172 |
//if( !defined('BNE_FRAMEWORK_VERSION') ) { |
| 173 |
// Flexslider |
| 174 |
wp_register_script( 'flexslider', BNE_TESTIMONIALS_URI . '/assets/js/flexslider.min.js', array('jquery'), '2.2.2', true ); |
| 175 |
//} |
| 176 |
|
| 177 |
// Load the plugin CSS |
| 178 |
wp_enqueue_style( 'bne-testimonials-css'); |
| 179 |
|
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
/* |
| 186 |
* |
| 187 |
* Register Admin CSS and JS |
| 188 |
* |
| 189 |
* @since v2.0 |
| 190 |
* |
| 191 |
*/ |
| 192 |
function admin_scripts( $hook ) { |
| 193 |
|
| 194 |
global $post; |
| 195 |
|
| 196 |
if( $hook == 'post-new.php' || $hook == 'post.php' ) { |
| 197 |
|
| 198 |
// Crosscheck with our Post Type list. |
| 199 |
if( 'bne_testimonials' == $post->post_type ) { |
| 200 |
|
| 201 |
// Finally, check if we're not on a BNE theme as this is already available from there. |
| 202 |
if( !defined('BNE_FRAMEWORK_VERSION') ) { |
| 203 |
wp_enqueue_style( 'bne-cmb-admin-css', BNE_TESTIMONIALS_URI . '/assets/css/bne-cmb-admin.css', '', BNE_TESTIMONIALS_VERSION, 'all' ); |
| 204 |
} |
| 205 |
|
| 206 |
} |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
|
| 211 |
} // END Class |
| 212 |
|
| 213 |
|
| 214 |
// Initiate the Class |
| 215 |
$BNE_Testimonials = new BNE_Testimonials(); |