main.php

Created Diff never expires
4 removals
199 lines
55 additions
250 lines
<?php
<?php


class VC_MEGA
class VC_MEGA
{
{
private $file;
private $file;


function __construct($file)
function __construct($file)
{
{
$this->file = $file;
$this->file = $file;
add_action( 'vc_before_init', array($this, 'vc_mega_addons' ));
add_action( 'vc_before_init', array($this, 'vc_mega_addons' ));
add_action('admin_menu', array($this, 'vc_register_admin_menu'));
add_action('admin_menu', array($this, 'vc_register_admin_menu'));
add_action('wp_ajax_vc_save_data', array($this, 'vc_saving_data' ));
add_action('wp_ajax_vc_save_data', array($this, 'vc_saving_data' ));
add_action( 'wp_enqueue_scripts', array($this, 'adding_front_scripts') );
add_action( 'wp_enqueue_scripts', array($this, 'adding_front_scripts') );
add_action('admin_enqueue_scripts', array($this, 'vc_admin_script'));
add_action('admin_enqueue_scripts', array($this, 'vc_admin_script'));
add_action( 'init', array( $this, 'check_if_vc_is_install' ) );
add_action( 'init', array( $this, 'check_if_vc_is_install' ) );
add_filter( 'plugin_action_links', array($this, 'action_links'), 10, 5 );
add_filter( 'plugin_action_links', array($this, 'action_links'), 10, 5 );
// register_activation_hook( __FILE__, array( $this, 'activation' ) );
// register_activation_hook( __FILE__, array( $this, 'activation' ) );
// remove_filter( 'the_content', 'wpautop' );
// remove_filter( 'the_content', 'wpautop' );
}
}


/**
/**
* init function.
* init function.
*
*
* @access public
* @access public
* @return void
* @return void
*/
*/
public function init () {
public function init () {
// Run this on activation.
// Run this on activation.
register_activation_hook( $this->file, array( $this, 'activation' ) );
register_activation_hook( $this->file, array( $this, 'activation' ) );
} // End init()
} // End init()


function adding_front_scripts () {
function adding_front_scripts () {
$saved_options = get_option('vc_save_data');
$saved_options = get_option('vc_save_data');
wp_enqueue_style( 'image-hover-effects-css', plugins_url( 'css/ihover.css' , __FILE__ ));
wp_enqueue_style( 'image-hover-effects-css', plugins_url( 'css/ihover.css' , __FILE__ ));
wp_enqueue_style( 'style-css', plugins_url( 'css/style.css' , __FILE__ ));
wp_enqueue_style( 'style-css', plugins_url( 'css/style.css' , __FILE__ ));
wp_enqueue_style( 'font-awesome-latest', plugins_url( 'css/font-awesome/css/all.css' , __FILE__ ));
wp_enqueue_style( 'font-awesome-latest', plugins_url( 'css/font-awesome/css/all.css' , __FILE__ ));
}
}


function vc_admin_script($slug) {
function vc_admin_script($slug) {
wp_enqueue_style( 'vc_admin_css', plugin_dir_url( __FILE__ ) . 'lib/style.css' );
wp_enqueue_style( 'vc_admin_css', plugin_dir_url( __FILE__ ) . 'lib/style.css' );
if ($slug == 'toplevel_page_mega-addons') {
if ($slug == 'toplevel_page_mega-addons') {
wp_enqueue_style( 'vc_admin_style', plugin_dir_url( __FILE__ ) . 'lib/admin.css' );
wp_enqueue_style( 'vc_admin_style', plugin_dir_url( __FILE__ ) . 'lib/admin.css' );
wp_enqueue_script( 'vc_admin_js', plugin_dir_url( __FILE__ ) . 'lib/admin.js', array('jquery', 'jquery-ui-core'));
wp_enqueue_script( 'vc_admin_js', plugin_dir_url( __FILE__ ) . 'lib/admin.js', array('jquery', 'jquery-ui-core'));
$vars = array(
'ajaxurl' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('mega_bk_admin'),
);
wp_localize_script( 'vc_admin_js', 'megaBkAdmin', $vars );
}
}
}
}




function vc_mega_addons() {
function vc_mega_addons() {
$saved_options = get_option('vc_save_data');
$saved_options = get_option('vc_save_data');
if (isset($saved_options['banner'])) {include 'render/infobanners.php';}
if (isset($saved_options['banner'])) {include 'render/infobanners.php';}
if (isset($saved_options['ihe'])) {include 'render/hover.php';}
if (isset($saved_options['ihe'])) {include 'render/hover.php';}
if (isset($saved_options['price_table'])) {include 'render/price.php';}
if (isset($saved_options['price_table'])) {include 'render/price.php';}
if (isset($saved_options['advance_price'])) {include 'render/advanceprice.php';}
if (isset($saved_options['advance_price'])) {include 'render/advanceprice.php';}
if (isset($saved_options['info_box'])) {include 'render/infobox.php';}
if (isset($saved_options['info_box'])) {include 'render/infobox.php';}
if (isset($saved_options['advance_btn'])) {include 'render/advanced_btn.php'; include 'render/hoverbutton.php';}
if (isset($saved_options['advance_btn'])) {include 'render/advanced_btn.php'; include 'render/hoverbutton.php';}
if (isset($saved_options['team_prof'])) {include 'render/teamprofile.php';}
if (isset($saved_options['team_prof'])) {include 'render/teamprofile.php';}
if (isset($saved_options['adv_carousel'])) {include 'render/tm_carousel_father.php';}
if (isset($saved_options['adv_carousel'])) {include 'render/tm_carousel_father.php';}
if (isset($saved_options['adv_carousel'])) {include 'render/tm_carousel_son.php';}
if (isset($saved_options['adv_carousel'])) {include 'render/tm_carousel_son.php';}
if (isset($saved_options['counter'])) {include 'render/statcounter.php';}
if (isset($saved_options['counter'])) {include 'render/statcounter.php';}
if (isset($saved_options['flip_box'])) {include 'render/flipbox.php';}
if (isset($saved_options['flip_box'])) {include 'render/flipbox.php';}
if (isset($saved_options['timeline'])) {include 'render/timeline_father.php';}
if (isset($saved_options['timeline'])) {include 'render/timeline_father.php';}
if (isset($saved_options['timeline'])) {include 'render/timeline_son.php';}
if (isset($saved_options['timeline'])) {include 'render/timeline_son.php';}
if (isset($saved_options['countdown'])) {include 'render/countdown.php';}
if (isset($saved_options['countdown'])) {include 'render/countdown.php';}
if (isset($saved_options['creative_link'])) {include 'render/creativelink.php';}
if (isset($saved_options['creative_link'])) {include 'render/creativelink.php';}
if (isset($saved_options['text_typer'])) {include 'render/texttyper.php';}
if (isset($saved_options['text_typer'])) {include 'render/texttyper.php';}
if (isset($saved_options['social_icon'])) {include 'render/social_father.php';}
if (isset($saved_options['social_icon'])) {include 'render/social_father.php';}
if (isset($saved_options['social_icon'])) {include 'render/social_son.php';}
if (isset($saved_options['social_icon'])) {include 'render/social_son.php';}
if (isset($saved_options['popup'])) {include 'render/modalPopup.php';}
if (isset($saved_options['popup'])) {include 'render/modalPopup.php';}
if (isset($saved_options['interactive_banner'])) {include 'render/interactivebanner.php';}
if (isset($saved_options['interactive_banner'])) {include 'render/interactivebanner.php';}
if (isset($saved_options['info_list'])) {include 'render/info_list_father.php';}
if (isset($saved_options['info_list'])) {include 'render/info_list_father.php';}
if (isset($saved_options['info_list'])) {include 'render/info_list_son.php';}
if (isset($saved_options['info_list'])) {include 'render/info_list_son.php';}
if (isset($saved_options['google_trend'])) {include 'render/googletrends.php';}
if (isset($saved_options['google_trend'])) {include 'render/googletrends.php';}
if (isset($saved_options['tooltip'])) {include 'render/tooltip_icons.php';}
if (isset($saved_options['tooltip'])) {include 'render/tooltip_icons.php';}
if (isset($saved_options['testimonial'])) {include 'render/testimonial.php';}
if (isset($saved_options['testimonial'])) {include 'render/testimonial.php';}
if (isset($saved_options['heading'])) {include 'render/headings.php';}
if (isset($saved_options['heading'])) {include 'render/headings.php';}
if (isset($saved_options['highlight_box'])) {include 'render/highlight_box.php';}
if (isset($saved_options['highlight_box'])) {include 'render/highlight_box.php';}
if (isset($saved_options['img_swap'])) {include 'render/image_swap.php';}
if (isset($saved_options['img_swap'])) {include 'render/image_swap.php';}
if (isset($saved_options['accordion'])) {include 'render/accordion_father.php';}
if (isset($saved_options['accordion'])) {include 'render/accordion_father.php';}
if (isset($saved_options['accordion'])) {include 'render/accordion_son.php';}
if (isset($saved_options['accordion'])) {include 'render/accordion_son.php';}
if (isset($saved_options['info_circle'])) {include 'render/info_circle.php';}
if (isset($saved_options['info_circle'])) {include 'render/info_circle.php';}
if (isset($saved_options['filter_gallery'])) {include 'render/filterablegallery_wrap.php';}
if (isset($saved_options['filter_gallery'])) {include 'render/filterablegallery_wrap.php';}
if (isset($saved_options['filter_gallery'])) {include 'render/filtergallery.php';}
if (isset($saved_options['filter_gallery'])) {include 'render/filtergallery.php';}
include 'includes/class-vc-number-param.php';
include 'includes/class-vc-number-param.php';
}
}


function vc_saving_data() {
function vc_saving_data() {
if (isset($_REQUEST)) {


// Sanitizing $_REQUEST before saving
if (
$vc_save_data = array_map( 'sanitize_text_field', $_REQUEST );
empty( $_POST['nonce'] ) ||
update_option( 'vc_save_data', $vc_save_data );
! is_string( $_POST['nonce'] ) ||
! wp_verify_nonce( $_POST['nonce'], 'mega_bk_admin' ) ||
! current_user_can('manage_options')
) {
header('HTTP/1.0 403 Forbidden');
echo 'ERR';
die();
}

$vc_default_options = array(
'banner',
'ihe',
'price_table',
'advance_price',
'info_box',
'advance_btn',
'team_prof',
'adv_carousel',
'counter',
'flip_box',
'timeline',
'countdown',
'creative_link',
'text_typer',
'social_icon',
'popup',
'interactive_banner',
'info_list',
'google_trend',
'tooltip',
'testimonial',
'heading',
'highlight_box',
'img_swap',
'accordion',
'info_circle',
'filter_gallery',
);


$save_data = [];
foreach ( $vc_default_options as $name ) {
if ( ! empty( $_POST[$name] ) && is_string( $_POST[$name] ) ) {
$save_data[$name] = sanitize_text_field( $_POST[$name] );
}
}
}

update_option( 'vc_save_data', $save_data );

echo "SAVED";
wp_die();
}
}




function vc_register_admin_menu() {
function vc_register_admin_menu() {
add_menu_page( 'Mega Addons', 'Mega Addons', 'manage_options', 'mega-addons', array($this, 'vc_addons'), 'dashicons-shield');
add_menu_page( 'Mega Addons', 'Mega Addons', 'manage_options', 'mega-addons', array($this, 'vc_addons'), 'dashicons-shield');
}
}


function vc_addons() {
function vc_addons() {
$saved_options = get_option('vc_save_data');
$saved_options = get_option('vc_save_data');
?>
?>
<div class="addons-admin-wrap">
<div class="addons-admin-wrap">
<h1>Mega Addons For WPBakery Page Builder</h1>
<h1>Mega Addons For WPBakery Page Builder</h1>
<h3>Welcome! You are about to begin with the most powerful addon for WPBakery Page Builder that add in many advanced features developed with love.</h3>
<h3>Welcome! You are about to begin with the most powerful addon for WPBakery Page Builder that add in many advanced features developed with love.</h3>
<br>
<br>
<h3 style="font-weight: 100;">Enable/Disable Element</h3>
<h3 style="font-weight: 100;">Enable/Disable Element</h3>
<div class="mega-addons-version">
<div class="mega-addons-version">
<div class="dashicons-before dashicons-shield"></div>
<div class="dashicons-before dashicons-shield"></div>
<p>Version 4.2.7</p>
<p>Version 4.2.7</p>
</div>
</div>
<?php include 'includes/settings.php'; ?>
<?php include 'includes/settings.php'; ?>
</div>
</div>




<?php }
<?php }


function check_if_vc_is_install(){
function check_if_vc_is_install(){
if ( ! defined( 'WPB_VC_VERSION' ) ) {
if ( ! defined( 'WPB_VC_VERSION' ) ) {
// Display notice that Visual Compser is required
// Display notice that Visual Compser is required
add_action('admin_notices', array( $this, 'showVcVersionNotice' ));
add_action('admin_notices', array( $this, 'showVcVersionNotice' ));
return;
return;
}
}
}
}


/**
/**
* activation function.
* activation function.
*
*
* @access public
* @access public
* @return void
* @return void
*/
*/
public function activation () {
public function activation () {


if ( !get_option( 'vc_save_data' ) ) {
if ( !get_option( 'vc_save_data' ) ) {
$vc_default_options = array(
$vc_default_options = array(
'banner' => 'on',
'banner' => 'on',
'ihe' => 'on',
'ihe' => 'on',
'price_table' => 'on',
'price_table' => 'on',
'advance_price' => 'on',
'advance_price' => 'on',
'info_box' => 'on',
'info_box' => 'on',
'advance_btn' => 'on',
'advance_btn' => 'on',
'team_prof' => 'on',
'team_prof' => 'on',
'adv_carousel' => 'on',
'adv_carousel' => 'on',
'counter' => 'on',
'counter' => 'on',
'flip_box' => 'on',
'flip_box' => 'on',
'timeline' => 'on',
'timeline' => 'on',
'countdown' => 'on',
'countdown' => 'on',
'creative_link' => 'on',
'creative_link' => 'on',
'text_typer' => 'on',
'text_typer' => 'on',
'social_icon' => 'on',
'social_icon' => 'on',
'popup' => 'on',
'popup' => 'on',
'interactive_banner' => 'on',
'interactive_banner' => 'on',
'info_list' => 'on',
'info_list' => 'on',
'google_trend' => 'on',
'google_trend' => 'on',
'tooltip' => 'on',
'tooltip' => 'on',
'testimonial' => 'on',
'testimonial' => 'on',
'heading' => 'on',
'heading' => 'on',
'highlight_box' => 'on',
'highlight_box' => 'on',
'img_swap' => 'on',
'img_swap' => 'on',
'accordion' => 'on',
'accordion' => 'on',
'info_circle' => 'on',
'info_circle' => 'on',
'filter_gallery' => 'on',
'filter_gallery' => 'on',
);
);


update_option( 'vc_save_data', $vc_default_options);
update_option( 'vc_save_data', $vc_default_options);
}
}
} // End activation()
} // End activation()


function showVcVersionNotice(){
function showVcVersionNotice(){
?>
?>
<div class="notice notice-warning is-dismissible">
<div class="notice notice-warning is-dismissible">
<p>Please install <a href="https://1.envato.market/A1QAx">WPBakery Page Builder</a> to use Mega Addons.</p>
<p>Please install <a href="https://1.envato.market/A1QAx">WPBakery Page Builder</a> to use Mega Addons.</p>
</div>
</div>
<?php
<?php
}
}


function action_links($actions, $plugin_file){
function action_links($actions, $plugin_file){
static $plugin;
static $plugin;


if (!isset($plugin))
if (!isset($plugin))
$plugin = plugin_basename(__FILE__);
$plugin = plugin_basename(__FILE__);
if ('mega-addons-for-visual-composer/index.php' == $plugin_file && defined('WPB_VC_VERSION')) {
if ('mega-addons-for-visual-composer/index.php' == $plugin_file && defined('WPB_VC_VERSION')) {


$site_link = array('upgrade' => '<a href="https://1.envato.market/02aNL" style="font-size: 14px;color: #11967A;" target="_blank"><b>Upgrade To Premium</b></a>');
$site_link = array('upgrade' => '<a href="https://1.envato.market/02aNL" style="font-size: 14px;color: #11967A;" target="_blank"><b>Upgrade To Premium</b></a>');
$actions = array_merge($site_link, $actions);
$actions = array_merge($site_link, $actions);
}
}
return $actions;
return $actions;
}
}


}
}


?>
?>