| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
/* |
| 6 |
Plugin Name: Pricing Table – Responsive & Easy Pricing Table |
| 7 |
Plugin URI: http://awplife.com/code |
| 8 |
Description: A Responsive pricing table Amazing Easy To Use Tables, Table, Pricing, Widget, Shortcode- Irresistible CSS Based WordPress pricing table Plugin. |
| 9 |
Version: 1.5.2 |
| 10 |
Requires PHP: 7.0 |
| 11 |
Author: A WP Life |
| 12 |
Author URI: http://awplife.com/ |
| 13 |
License: GPLv2 or later |
| 14 |
Text Domain: abc-pricing-table |
| 15 |
Domain Path: /languages |
| 16 |
*/ |
| 17 |
if (!class_exists('apt_pricingtable')) { |
| 18 |
class apt_pricingtable |
| 19 |
{ |
| 20 |
|
| 21 |
public function __construct() |
| 22 |
{ |
| 23 |
$this->_constants(); |
| 24 |
$this->_hooks(); |
| 25 |
} |
| 26 |
|
| 27 |
protected function _constants() |
| 28 |
{ |
| 29 |
// Plugin Version |
| 30 |
define('APT_PLUGIN_VER', '1.5.2'); |
| 31 |
|
| 32 |
// Plugin Text Domain |
| 33 |
define('APT_TXTDM', 'abc-pricing-table'); |
| 34 |
|
| 35 |
// Plugin Name |
| 36 |
define('APT_PLUGIN_NAME', __('Pricing', 'abc-pricing-table')); |
| 37 |
|
| 38 |
// Plugin Slug |
| 39 |
define('APT_PLUGIN_SLUG', 'abc-pricing'); |
| 40 |
|
| 41 |
// Plugin Directory Path |
| 42 |
define('APT_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
| 43 |
|
| 44 |
// Plugin Directory URL |
| 45 |
define('APT_PLUGIN_URL', plugin_dir_url(__FILE__)); |
| 46 |
|
| 47 |
define('APT_SECURE_KEY', md5(NONCE_KEY)); |
| 48 |
|
| 49 |
} // end of constructor function |
| 50 |
|
| 51 |
protected function _hooks() |
| 52 |
{ |
| 53 |
// Load text domain |
| 54 |
add_action('plugins_loaded', array($this, 'load_textdomain')); |
| 55 |
|
| 56 |
// add testimonial menu item, change menu filter for multisite |
| 57 |
add_action('admin_menu', array($this, 'pricing_menu'), 101); |
| 58 |
|
| 59 |
// Create pricing table Custom Post |
| 60 |
add_action('init', array($this, 'Pricing')); |
| 61 |
|
| 62 |
// Add meta box to custom post |
| 63 |
add_action('add_meta_boxes', array($this, 'admin_add_meta_box')); |
| 64 |
|
| 65 |
// loaded during admin init |
| 66 |
add_action('admin_init', array($this, 'admin_add_meta_box')); |
| 67 |
|
| 68 |
add_action('save_post', array(&$this, '_apt_save_settings')); |
| 69 |
|
| 70 |
// Shortcode Compatibility in Text Widgets |
| 71 |
add_action('widget_text', 'do_shortcode'); |
| 72 |
|
| 73 |
// add pfg cpt shortcode column - manage_{$post_type}_posts_columns |
| 74 |
add_filter('manage_abc-pricing_posts_columns', array(&$this, 'set_abc_pricing_shortcode_column_name')); |
| 75 |
|
| 76 |
// add pfg cpt shortcode column data - manage_{$post_type}_posts_custom_column |
| 77 |
add_action('manage_abc-pricing_posts_custom_column', array(&$this, 'custom_abc_pricing_shodrcode_data'), 10, 2); |
| 78 |
|
| 79 |
} // end of hook function |
| 80 |
|
| 81 |
|
| 82 |
// end of hook function |
| 83 |
|
| 84 |
// Pricing table cpt shortcode column before date columns |
| 85 |
public function set_abc_pricing_shortcode_column_name($defaults) |
| 86 |
{ |
| 87 |
$new = array(); |
| 88 |
$shortcode = $columns['abc_pricing_shortcode']; // save the tags column |
| 89 |
unset($defaults['tags']); // remove it from the columns list |
| 90 |
|
| 91 |
foreach ($defaults as $key => $value) { |
| 92 |
if ($key == 'date') { // when we find the date column |
| 93 |
$new['abc_pricing_shortcode'] = __('Shortcode', 'abc-pricing-table'); // put the tags column before it |
| 94 |
} |
| 95 |
$new[$key] = $value; |
| 96 |
} |
| 97 |
return $new; |
| 98 |
} |
| 99 |
|
| 100 |
// abc cpt shortcode column data |
| 101 |
public function custom_abc_pricing_shodrcode_data($column, $post_id) |
| 102 |
{ |
| 103 |
switch ($column) { |
| 104 |
case 'abc_pricing_shortcode': |
| 105 |
echo "<input type='text' class='button button-primary' id='abc-pricing-shortcode-" . esc_attr($post_id) . "' value='[APT id=" . esc_attr($post_id) . "]' style='font-weight:bold; background-color:#32373C; color:#FFFFFF; text-align:center;' />"; |
| 106 |
echo "<input type='button' class='button button-primary' onclick='return ABCCopyShortcode" . esc_attr($post_id) . "();' readonly value='Copy' style='margin-left:4px;' />"; |
| 107 |
echo "<span id='copy-msg-" . esc_attr($post_id) . "' class='button button-primary' style='display:none; background-color:#32CD32; color:#FFFFFF; margin-left:4px; border-radius: 4px;'>copied</span>"; |
| 108 |
echo '<script> |
| 109 |
function ABCCopyShortcode' . esc_attr($post_id) . "() { |
| 110 |
var copyText = document.getElementById('abc-pricing-shortcode-" . esc_attr($post_id) . "'); |
| 111 |
copyText.select(); |
| 112 |
document.execCommand('copy'); |
| 113 |
|
| 114 |
//fade in and out copied message |
| 115 |
jQuery('#copy-msg-" . esc_attr($post_id) . "').fadeIn('1000', 'linear'); |
| 116 |
jQuery('#copy-msg-" . esc_attr($post_id) . "').fadeOut(2500,'swing'); |
| 117 |
} |
| 118 |
</script> |
| 119 |
"; |
| 120 |
break; |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
public function load_textdomain() |
| 126 |
{ |
| 127 |
load_plugin_textdomain('abc-pricing-table', false, dirname(plugin_basename(__FILE__)) . '/languages'); |
| 128 |
} |
| 129 |
|
| 130 |
public function pricing_menu() |
| 131 |
{ |
| 132 |
$plugins_help_menu = add_submenu_page('edit.php?post_type=' . APT_PLUGIN_SLUG, __('Our Plugins', 'abc-pricing-table'), __('Our Plugins', 'abc-pricing-table'), 'administrator', 'pricing-featured-plugins-page', array($this, '_abcpt_featured_plugins')); |
| 133 |
} |
| 134 |
|
| 135 |
public function Pricing() |
| 136 |
{ |
| 137 |
$labels = array( |
| 138 |
'name' => __('Pricing Table', 'abc-pricing-table'), |
| 139 |
'singular_name' => __('Pricing Table', 'abc-pricing-table'), |
| 140 |
'menu_name' => __('Pricing Table', 'abc-pricing-table'), |
| 141 |
'name_admin_bar' => __('Pricing Table', 'abc-pricing-table'), |
| 142 |
'add_new' => __('Add Pricing Table', 'abc-pricing-table'), |
| 143 |
'add_new_item' => __('Add Pricing Table', 'abc-pricing-table'), |
| 144 |
'new_item' => __('New Pricing Table', 'abc-pricing-table'), |
| 145 |
'edit_item' => __('Edit Pricing Table', 'abc-pricing-table'), |
| 146 |
'view_item' => __('View Pricing Table', 'abc-pricing-table'), |
| 147 |
'all_items' => __('All Pricing Table', 'abc-pricing-table'), |
| 148 |
'search_items' => __('Search Pricing Table', 'abc-pricing-table'), |
| 149 |
'parent_item_colon' => __('Parent Pricing Table', 'abc-pricing-table'), |
| 150 |
'not_found' => __('No Pricing Table', 'abc-pricing-table'), |
| 151 |
'not_found_in_trash' => __('No Pricing Table found in Trash', 'abc-pricing-table'), |
| 152 |
); |
| 153 |
|
| 154 |
$args = array( |
| 155 |
'labels' => __('Pricing Table', 'abc-pricing-table'), |
| 156 |
'description' => __('Description', 'abc-pricing-table'), |
| 157 |
'labels' => $labels, |
| 158 |
'public' => true, |
| 159 |
'publicly_queryable' => true, |
| 160 |
'show_ui' => true, |
| 161 |
'show_in_menu' => true, |
| 162 |
'query_var' => true, |
| 163 |
// 'rewrite' => array( 'slug' => 'pricing' ), |
| 164 |
'capability_type' => 'page', |
| 165 |
'has_archive' => true, |
| 166 |
'hierarchical' => false, |
| 167 |
'menu_icon' => 'dashicons-cart', |
| 168 |
'menu_position' => null, |
| 169 |
'supports' => array('title'), |
| 170 |
); |
| 171 |
register_post_type('abc-pricing', $args); |
| 172 |
} |
| 173 |
|
| 174 |
public function admin_add_meta_box() |
| 175 |
{ |
| 176 |
add_meta_box(__('Add Pricing Table', 'abc-pricing-table'), __('Add Pricing Table', 'abc-pricing-table'), array(&$this, 'apt_pricing_upload'), 'abc-pricing', 'normal', 'default'); |
| 177 |
add_meta_box(__('Upgrade Pricing Table Pro', 'abc-pricing-table'), __('Upgrade Pricing Table Pro', 'abc-pricing-table'), array(&$this, 'apt_upgrade_pro'), 'abc-pricing', 'side', 'default'); |
| 178 |
add_meta_box(__('Rate Our Plugin', 'abc-pricing-table'), __('Rate Our Plugin', 'abc-pricing-table'), array(&$this, 'apt_rate_plugin'), 'abc-pricing', 'side', 'default'); |
| 179 |
} |
| 180 |
/** meta upgrade pro **/ |
| 181 |
public function apt_upgrade_pro() |
| 182 |
{ ?> |
| 183 |
<img src="<?php echo esc_url(plugin_dir_url(__FILE__) . 'assets/img/2017-12-08_20-43-13.png'); ?>" width="250" |
| 184 |
height="280"> |
| 185 |
<a href="https://awplife.com/demo/pricing-table-premium/" target="_new" class="button button-primary button-large" |
| 186 |
style="background: #496481; text-shadow: none; margin-top:10px"><span class="dashicons dashicons-search" |
| 187 |
style="line-height:1.4;"></span> Live Demo</a> |
| 188 |
<a href="https://awplife.com/wordpress-plugins/pricing-table-wordpress-plugin/" target="_new" |
| 189 |
class="button button-primary button-large" style="background: #496481; text-shadow: none; margin-top:10px"><span |
| 190 |
class="dashicons dashicons-unlock" style="line-height:1.4;"></span> Upgrade Pro</a> |
| 191 |
<?php |
| 192 |
} |
| 193 |
/** meta rate us **/ |
| 194 |
public function apt_rate_plugin() |
| 195 |
{ |
| 196 |
?> |
| 197 |
<div style="text-align:center"> |
| 198 |
<p>If you like our plugin then please <b>Rate us</b> on WordPress</p> |
| 199 |
</div> |
| 200 |
<div style="text-align:center"> |
| 201 |
<span class="dashicons dashicons-star-filled"></span> |
| 202 |
<span class="dashicons dashicons-star-filled"></span> |
| 203 |
<span class="dashicons dashicons-star-filled"></span> |
| 204 |
<span class="dashicons dashicons-star-filled"></span> |
| 205 |
<span class="dashicons dashicons-star-filled"></span> |
| 206 |
</div> |
| 207 |
<br> |
| 208 |
<div style="text-align:center"> |
| 209 |
<a href="https://wordpress.org/support/plugin/abc-pricing-table/reviews/?filter=5" target="_new" |
| 210 |
class="button button-primary button-large" style="background: #496481; text-shadow: none;"><span |
| 211 |
class="dashicons dashicons-heart" style="line-height:1.4;"></span> Please Rate Us</a> |
| 212 |
</div> |
| 213 |
<?php } |
| 214 |
|
| 215 |
public function apt_pricing_upload($post) |
| 216 |
{ |
| 217 |
|
| 218 |
require_once 'include/add-new-pricing.php'; |
| 219 |
|
| 220 |
wp_nonce_field('apt_post_save_settings', 'apt_post_save_nonce'); |
| 221 |
} |
| 222 |
|
| 223 |
public function _apt_save_settings($post_id) |
| 224 |
{ |
| 225 |
if (isset($_POST['apt_post_save_nonce'])) { |
| 226 |
$nonce = wp_unslash($_POST['apt_post_save_nonce']); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 227 |
if (wp_verify_nonce($nonce, 'apt_post_save_settings')) { |
| 228 |
|
| 229 |
$total_cols = isset($_POST['total_cols']) ? sanitize_text_field(wp_unslash($_POST['total_cols'])) : ''; |
| 230 |
$pricing_table_design = isset($_POST['pricing_table_design']) ? sanitize_text_field(wp_unslash($_POST['pricing_table_design'])) : ''; |
| 231 |
$currency_icon = isset($_POST['currency_icon']) ? sanitize_text_field(wp_unslash($_POST['currency_icon'])) : ''; |
| 232 |
$heading_text_color = isset($_POST['heading_text_color']) ? sanitize_text_field(wp_unslash($_POST['heading_text_color'])) : ''; |
| 233 |
$heading_background_color = isset($_POST['heading_background_color']) ? sanitize_text_field(wp_unslash($_POST['heading_background_color'])) : ''; |
| 234 |
$button_color = isset($_POST['button_color']) ? sanitize_text_field(wp_unslash($_POST['button_color'])) : ''; |
| 235 |
$button_hover_color = isset($_POST['button_hover_color']) ? sanitize_text_field(wp_unslash($_POST['button_hover_color'])) : ''; |
| 236 |
$background_hover_color = isset($_POST['background_hover_color']) ? sanitize_text_field(wp_unslash($_POST['background_hover_color'])) : ''; |
| 237 |
$button_heading_color = isset($_POST['button_heading_color']) ? sanitize_text_field(wp_unslash($_POST['button_heading_color'])) : ''; |
| 238 |
$feature_heading_text_color = isset($_POST['feature_heading_text_color']) ? sanitize_text_field(wp_unslash($_POST['feature_heading_text_color'])) : ''; |
| 239 |
$feature_button_color = isset($_POST['feature_button_color']) ? sanitize_text_field(wp_unslash($_POST['feature_button_color'])) : ''; |
| 240 |
$feature_heading_background_color = isset($_POST['feature_heading_background_color']) ? sanitize_text_field(wp_unslash($_POST['feature_heading_background_color'])) : ''; |
| 241 |
$feature_button_heading_color = isset($_POST['feature_button_heading_color']) ? sanitize_text_field(wp_unslash($_POST['feature_button_heading_color'])) : ''; |
| 242 |
$feature_background_hover_color = isset($_POST['feature_background_hover_color']) ? sanitize_text_field(wp_unslash($_POST['feature_background_hover_color'])) : ''; |
| 243 |
$feature_button_hover_color = isset($_POST['feature_button_hover_color']) ? sanitize_text_field(wp_unslash($_POST['feature_button_hover_color'])) : ''; |
| 244 |
|
| 245 |
$apt_custom_css = isset($_POST['apt_custom_css']) ? wp_kses(wp_unslash($_POST['apt_custom_css']), array(), array()) : ''; |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
$pricing_name = array(); |
| 250 |
$pricing_name_val = isset($_POST['pricing_name']) ? array_map('sanitize_text_field', wp_unslash((array) $_POST['pricing_name'])) : array(); |
| 251 |
$apt_i = 0; |
| 252 |
|
| 253 |
foreach ($pricing_name_val as $pricing_name_v) { |
| 254 |
|
| 255 |
$featured_button[] = isset($_POST['featured_button'][$apt_i]) ? sanitize_text_field(wp_unslash($_POST['featured_button'][$apt_i])) : ''; |
| 256 |
$pricing_name[] = isset($_POST['pricing_name'][$apt_i]) ? sanitize_text_field(wp_unslash($_POST['pricing_name'][$apt_i])) : ''; |
| 257 |
$pricing_price[] = isset($_POST['pricing_price'][$apt_i]) ? sanitize_text_field(wp_unslash($_POST['pricing_price'][$apt_i])) : ''; |
| 258 |
$pricing_plan[] = isset($_POST['pricing_plan'][$apt_i]) ? sanitize_text_field(wp_unslash($_POST['pricing_plan'][$apt_i])) : ''; |
| 259 |
$pricing_features[] = isset($_POST['pricing_features'][$apt_i]) ? sanitize_textarea_field(wp_unslash($_POST['pricing_features'][$apt_i])) : ''; |
| 260 |
$pricing_btn_text[] = isset($_POST['pricing_btn_text'][$apt_i]) ? sanitize_text_field(wp_unslash($_POST['pricing_btn_text'][$apt_i])) : ''; |
| 261 |
$pricing_btn_url[] = isset($_POST['pricing_btn_url'][$apt_i]) ? sanitize_text_field(wp_unslash($_POST['pricing_btn_url'][$apt_i])) : ''; |
| 262 |
$pricing_icon_pick[] = isset($_POST['pricing_icon_pick'][$apt_i]) ? sanitize_text_field(wp_unslash($_POST['pricing_icon_pick'][$apt_i])) : ''; |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
$apt_i++; |
| 267 |
} |
| 268 |
|
| 269 |
$pricing_post_settings = array( |
| 270 |
|
| 271 |
'featured_button' => $featured_button, |
| 272 |
'pricing_name' => $pricing_name, |
| 273 |
'pricing_price' => $pricing_price, |
| 274 |
'pricing_plan' => $pricing_plan, |
| 275 |
'pricing_features' => $pricing_features, |
| 276 |
'pricing_btn_text' => $pricing_btn_text, |
| 277 |
'pricing_btn_url' => $pricing_btn_url, |
| 278 |
'pricing_icon_pick' => $pricing_icon_pick, |
| 279 |
'total_cols' => $total_cols, |
| 280 |
'pricing_table_design' => $pricing_table_design, |
| 281 |
'currency_icon' => $currency_icon, |
| 282 |
'heading_text_color' => $heading_text_color, |
| 283 |
'heading_background_color' => $heading_background_color, |
| 284 |
'button_color' => $button_color, |
| 285 |
'button_hover_color' => $button_hover_color, |
| 286 |
'background_hover_color' => $background_hover_color, |
| 287 |
'button_heading_color' => $button_heading_color, |
| 288 |
'feature_heading_text_color' => $feature_heading_text_color, |
| 289 |
'feature_button_color' => $feature_button_color, |
| 290 |
'feature_heading_background_color' => $feature_heading_background_color, |
| 291 |
'feature_button_heading_color' => $feature_button_heading_color, |
| 292 |
'feature_background_hover_color' => $feature_background_hover_color, |
| 293 |
'feature_button_hover_color' => $feature_button_hover_color, |
| 294 |
'apt_custom_css' => $apt_custom_css, |
| 295 |
|
| 296 |
); |
| 297 |
|
| 298 |
$meta_key = 'apt_pricing_table_data_' . $post_id; |
| 299 |
update_post_meta($post_id, $meta_key, $pricing_post_settings); |
| 300 |
|
| 301 |
} else { |
| 302 |
wp_die(esc_html__('Sorry, your nonce did not verify.', 'abc-pricing-table')); |
| 303 |
} |
| 304 |
} |
| 305 |
} |
| 306 |
public function _abcpt_featured_plugins() |
| 307 |
{ |
| 308 |
require_once 'featured-plugins/featured-plugins.php'; |
| 309 |
} |
| 310 |
} |
| 311 |
|
| 312 |
// register sf scripts |
| 313 |
function awplife_apt_register_scripts() |
| 314 |
{ |
| 315 |
|
| 316 |
// css & JS |
| 317 |
wp_enqueue_script('jquery'); |
| 318 |
wp_register_script('apt-bootstrap-min-js', plugin_dir_url(__FILE__) . 'assets/js/bootstrap.min.js'); |
| 319 |
wp_register_style('apt-pricing-frontend-bootstrap-css', plugin_dir_url(__FILE__) . 'assets/css/pricing-frontend-bootstrap.css'); |
| 320 |
wp_register_style('apt-all-css', plugin_dir_url(__FILE__) . 'assets/css/all.css'); |
| 321 |
// css & JS |
| 322 |
} |
| 323 |
add_action('wp_enqueue_scripts', 'awplife_apt_register_scripts'); |
| 324 |
|
| 325 |
// Plugin Recommend |
| 326 |
add_action('tgmpa_register', 'APT_TXTDM_plugin_recommend'); |
| 327 |
function APT_TXTDM_plugin_recommend() |
| 328 |
{ |
| 329 |
$plugins = array( |
| 330 |
array( |
| 331 |
'name' => 'Portfolio Filter Gallery', |
| 332 |
'slug' => 'portfolio-filter-gallery', |
| 333 |
'required' => false, |
| 334 |
), |
| 335 |
array( |
| 336 |
'name' => 'Blog Filter & Post Portfolio', |
| 337 |
'slug' => 'blog-filter', |
| 338 |
'required' => false, |
| 339 |
), |
| 340 |
array( |
| 341 |
'name' => 'Team Builder Member Showcase', |
| 342 |
'slug' => 'team-builder-member-showcase', |
| 343 |
'required' => false, |
| 344 |
), |
| 345 |
); |
| 346 |
tgmpa($plugins); |
| 347 |
} |
| 348 |
|
| 349 |
|
| 350 |
$new_pricingtable_object = new apt_pricingtable(); |
| 351 |
require_once 'shotcode.php'; |
| 352 |
require_once 'class-tgm-plugin-activation.php'; |
| 353 |
} |
| 354 |
?> |