| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WC Builder - WooCommerce Page Builder for WPBakery |
| 4 |
* Description: The WooCommerce elements library for WPBakery page builder plugin for WordPress. |
| 5 |
* Plugin URI: http://hasthemes.com |
| 6 |
* Version: 1.2.3 |
| 7 |
* Author: HasThemes |
| 8 |
* Author URI: http://hasthemes.com |
| 9 |
* License: GPL-2.0+ |
| 10 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 11 |
* Text Domain: wpbforwpbakery |
| 12 |
* Domain Path: /languages |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 16 |
|
| 17 |
define( 'WPBFORWPBAKERY_VERSION', '1.2.3' ); |
| 18 |
define( 'WPBFORWPBAKERY_ADDONS_PL_URL', plugins_url( '/', __FILE__ ) ); |
| 19 |
define( 'WPBFORWPBAKERY_ADDONS_PL_PATH', plugin_dir_path( __FILE__ ) ); |
| 20 |
define( 'WPBFORWPBAKERY_ADDONS_PL_ROOT', __FILE__ ); |
| 21 |
|
| 22 |
// Deactivate the pro plugin |
| 23 |
register_activation_hook( WPBFORWPBAKERY_ADDONS_PL_ROOT, 'wpbforwpbakery_activation_hook' ); |
| 24 |
function wpbforwpbakery_activation_hook(){ |
| 25 |
if ( ! function_exists('is_plugin_active') ){ |
| 26 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 27 |
} |
| 28 |
|
| 29 |
if( is_plugin_active('wc-builder-pro/wc-builder-pro.php') ){ |
| 30 |
add_action('update_option_active_plugins', function(){ |
| 31 |
deactivate_plugins('wc-builder-pro/wc-builder-pro.php'); |
| 32 |
}); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
// Required File |
| 37 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'includes/helper-functions.php'; |
| 38 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'includes/activation-notice.php'; |
| 39 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'includes/custom-posts.php'; |
| 40 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'includes/admin/admin-init.php'; |
| 41 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'includes/metaboxes.php'; |
| 42 |
|
| 43 |
if(is_admin()){ |
| 44 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'includes/admin/recommended-plugins/class.recommended-plugins.php'; |
| 45 |
add_action('init', function() { |
| 46 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'includes/admin/recommended-plugins/recommendations.php'; |
| 47 |
}); |
| 48 |
|
| 49 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'includes/admin/dashboard-widget/class-api.php'; |
| 50 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'includes/admin/dashboard-widget/class-dashboard-widget.php'; |
| 51 |
} |
| 52 |
|
| 53 |
if( wpbforwpbakery_get_option('ajaxcart_singleproduct', 'wpbforwpbakery_other_tabs') === 'on' ){ |
| 54 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH . 'includes/single-add-to-cart-ajax.php'; |
| 55 |
} |
| 56 |
|
| 57 |
add_action('plugins_loaded', 'wpbforwpbakery_initialize_plugin'); |
| 58 |
function wpbforwpbakery_initialize_plugin(){ |
| 59 |
require_once WPBFORWPBAKERY_ADDONS_PL_PATH.'init.php'; |
| 60 |
} |
| 61 |
|
| 62 |
// enqueue scripts |
| 63 |
add_action( 'wp_enqueue_scripts','wpbforwpbakery_enqueue_scripts'); |
| 64 |
function wpbforwpbakery_enqueue_scripts(){ |
| 65 |
// enqueue styles |
| 66 |
wp_enqueue_style( 'wpbforwpbakery-main', WPBFORWPBAKERY_ADDONS_PL_URL.'/assets/css/main.css', array(), WPBFORWPBAKERY_VERSION ); |
| 67 |
|
| 68 |
// dynamic style |
| 69 |
$site_width = wpbforwpbakery_get_option( 'content_width', 'wpbforwpbakery_woo_template_tabs', '1170' ); |
| 70 |
$site_width = wpbforwpbakery_sanitize_css_value( $site_width ); // Sanitize to prevent XSS |
| 71 |
$data = ''; |
| 72 |
if($site_width){ |
| 73 |
$data = " |
| 74 |
.wpbforwpbakery_archive .vc_row.wpb_row.vc_row-fluid, |
| 75 |
.wpbforwpbakery-single-product .vc_row.wpb_row.vc_row-fluid, |
| 76 |
.wpbforwpbakery-page-template .vc_row.wpb_row.vc_row-fluid{ |
| 77 |
max-width: $site_width; |
| 78 |
margin: 0 auto; |
| 79 |
} |
| 80 |
.wpbforwpbakery_archive .vc_row.wpb_row.vc_row-fluid[data-vc-full-width='true'], |
| 81 |
.wpbforwpbakery-single-product .vc_row.wpb_row.vc_row-fluid[data-vc-full-width='true'], |
| 82 |
.wpbforwpbakery-page-template .vc_row.wpb_row.vc_row-fluid[data-vc-full-width='true']{ |
| 83 |
max-width:100%; |
| 84 |
} |
| 85 |
"; |
| 86 |
} |
| 87 |
wp_add_inline_style( 'wpbforwpbakery-main', $data ); |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
//Register a custom menu page. |
| 92 |
add_action( 'admin_menu', 'wpbforwpbakery_register_menu_page' ); |
| 93 |
function wpbforwpbakery_register_menu_page() { |
| 94 |
add_menu_page( |
| 95 |
__( 'WC Page Builder', 'wpbforwpbakery' ), |
| 96 |
'WC Page Builder', |
| 97 |
'manage_options', |
| 98 |
'wpbforwpbakery_options', |
| 99 |
'', |
| 100 |
WPBFORWPBAKERY_ADDONS_PL_URL.'includes/admin/assets/images/menu-icon.png' |
| 101 |
); |
| 102 |
} |
| 103 |
|
| 104 |
// set vc editor to post type |
| 105 |
add_action('plugins_loaded', 'wpbforwpbakery_fire_vc_before_init'); |
| 106 |
function wpbforwpbakery_fire_vc_before_init(){ |
| 107 |
add_action('vc_before_init', 'wpbforwpbakery_set_post_type_to_vc_editor'); |
| 108 |
} |
| 109 |
|
| 110 |
function wpbforwpbakery_set_post_type_to_vc_editor(){ |
| 111 |
if (function_exists('vc_set_default_editor_post_types')) { |
| 112 |
vc_set_default_editor_post_types(array('page', 'post', 'wpbfwpb_template')); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
// Bind admin page link to the plugin action link. |
| 117 |
add_filter( 'plugin_action_links_wc-builder/wc-builder.php', 'wpbforwpbakery_action_links_add', 10, 4 ); |
| 118 |
function wpbforwpbakery_action_links_add( $actions, $plugin_file, $plugin_data, $context ){ |
| 119 |
$settings_page_link = sprintf( |
| 120 |
/* |
| 121 |
* translators: |
| 122 |
* 1: Settings label |
| 123 |
*/ |
| 124 |
'<a href="'. esc_url( get_admin_url() . 'edit.php?post_type=wpbfwpb_template' ) .'">%1$s</a>', |
| 125 |
esc_html__( 'Settings', 'wpbforwpbakery' ) |
| 126 |
); |
| 127 |
|
| 128 |
array_unshift( $actions, $settings_page_link ); |
| 129 |
|
| 130 |
return $actions; |
| 131 |
} |
| 132 |
|