public function __construct($composer) { $this->tabs = array('general' => __('General Settings', 'js_composer')); $composer = WPBakeryVisualComposer::getInstance(); if ($composer->isPlugin() && !$composer->settingsAsTheme()) { $this->tabs['color'] = __('Design Options', 'js_composer'); $this->tabs['element_css'] = __('Element Class Names', 'js_composer'); $this->tabs['custom_css'] = __('Custom CSS', 'js_composer'); } if (!$composer->updaterDisabled()) { $this->tabs['updater'] = __('Product License', 'js_composer'); } $this->tabs = apply_filters('vc_settings_tabs', $this->tabs); if (!empty($_COOKIE['wpb_js_composer_settings_active_tab']) && isset($this->tabs[str_replace('#vc-settings-', '', $_COOKIE['wpb_js_composer_settings_active_tab'])])) { $this->active_tab = str_replace('#vc-settings-', '', $_COOKIE['wpb_js_composer_settings_active_tab']); } else { if (!empty($_GET['tab']) && isset($this->tabs[$_GET['tab']])) { $this->active_tab = $_GET['tab']; } else { $this->active_tab = 'general'; } } $this->composer = $composer; self::$color_settings = array(array('vc_color' => array('title' => __('Main accent color', 'js_composer'))), array('vc_color_hover' => array('title' => __('Hover color', 'js_composer'))), array('vc_color_call_to_action_bg' => array('title' => __('Call to action background color', 'js_composer'))), array('vc_color_google_maps_bg' => array('title' => __('Google maps background color', 'js_composer'))), array('vc_color_post_slider_caption_bg' => array('title' => __('Post slider caption background color', 'js_composer'))), array('vc_color_progress_bar_bg' => array('title' => __('Progress bar background color', 'js_composer'))), array('vc_color_separator_border' => array('title' => __('Separator border color', 'js_composer'))), array('vc_color_tab_bg' => array('title' => __('Tabs navigation background color', 'js_composer'))), array('vc_color_tab_bg_active' => array('title' => __('Active tab background color', 'js_composer')))); self::$defaults = array('vc_color' => '#f7f7f7', 'vc_color_hover' => '#F0F0F0', 'margin' => '35px', 'gutter' => '2.5', 'responsive_max' => '480'); $vc_action = !empty($_POST['vc_action']) ? $_POST['vc_action'] : (!empty($_GET['vc_action']) ? $_GET['vc_action'] : ''); if ($vc_action == 'restore_color') { $this->restoreColor(); } elseif ($vc_action == 'remove_all_css_classes') { $this->removeAllCssClasses(); } }
protected function getDownloadUrl() { global $wp_filesystem; $this->skin->feedback('download_envato'); $package_filename = 'js_composer.zip'; $res = $this->fs_connect(array(WP_CONTENT_DIR)); if (!$res) { return new WP_Error('no_credentials', __("Error! Can't connect to filesystem", 'js_composer')); } $username = WPBakeryVisualComposerSettings::get('envato_username'); $api_key = WPBakeryVisualComposerSettings::get('envato_api_key'); $purchase_code = WPBakeryVisualComposerSettings::get('js_composer_purchase_code'); if (empty($username) || empty($api_key) || empty($purchase_code)) { return new WP_Error('no_credentials', __('Error! Envato username, api key and your purchase code are required for downloading updates from Envato marketplace for the Visual Composer. Visit <a href="' . admin_url('options-general.php?page=wpb_vc_settings&tab=updater') . '' . '">Settings</a> to fix.', 'js_composer')); } $json = wp_remote_get($this->envatoDownloadPurchaseUrl($username, $api_key, $purchase_code)); $result = json_decode($json['body'], true); if (!isset($result['download-purchase']['download_url'])) { return new WP_Error('no_credentials', __('Error! Envato API error' . (isset($result['error']) ? ': ' . $result['error'] : '.'), 'js_composer')); } $result['download-purchase']['download_url']; $download_file = download_url($result['download-purchase']['download_url']); if (is_wp_error($download_file)) { return $download_file; } $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade_tmp/js_composer_envato_package'; if (is_dir($upgrade_folder)) { $wp_filesystem->delete($upgrade_folder); } $result = unzip_file($download_file, $upgrade_folder); if ($result && is_file($upgrade_folder . '/' . $package_filename)) { return $upgrade_folder . '/' . $package_filename; } return new WP_Error('no_credentials', __('Error on unzipping package', 'js_composer')); }
public function __construct($composer) { $this->composer = WPBakeryVisualComposer::getInstance(); $this->setTabs(); $this->tabs = apply_filters('vc_settings_tabs', $this->tabs); if (!empty($_COOKIE['wpb_js_composer_settings_active_tab']) && isset($this->tabs[str_replace('#vc-settings-', '', $_COOKIE['wpb_js_composer_settings_active_tab'])])) { $this->active_tab = str_replace('#vc-settings-', '', $_COOKIE['wpb_js_composer_settings_active_tab']); } else { if (!empty($_GET['tab']) && isset($this->tabs[$_GET['tab']])) { $this->active_tab = $_GET['tab']; } elseif (!$this->showConfigurationTabs()) { $this->active_tab = 'updater'; } else { $this->active_tab = 'general'; } } self::$color_settings = array(array('vc_color' => array('title' => __('Main accent color', LANGUAGE_ZONE))), array('vc_color_hover' => array('title' => __('Hover color', LANGUAGE_ZONE))), array('vc_color_call_to_action_bg' => array('title' => __('Call to action background color', LANGUAGE_ZONE))), array('vc_color_google_maps_bg' => array('title' => __('Google maps background color', LANGUAGE_ZONE))), array('vc_color_post_slider_caption_bg' => array('title' => __('Post slider caption background color', LANGUAGE_ZONE))), array('vc_color_progress_bar_bg' => array('title' => __('Progress bar background color', LANGUAGE_ZONE))), array('vc_color_separator_border' => array('title' => __('Separator border color', LANGUAGE_ZONE))), array('vc_color_tab_bg' => array('title' => __('Tabs navigation background color', LANGUAGE_ZONE))), array('vc_color_tab_bg_active' => array('title' => __('Active tab background color', LANGUAGE_ZONE)))); self::$defaults = array('vc_color' => '#f7f7f7', 'vc_color_hover' => '#F0F0F0', 'margin' => '35px', 'gutter' => '15', 'responsive_max' => '768'); $vc_action = !empty($_POST['vc_action']) ? $_POST['vc_action'] : (!empty($_GET['vc_action']) ? $_GET['vc_action'] : ''); if ($vc_action == 'restore_color') { $this->restoreColor(); } elseif ($vc_action == 'remove_all_css_classes') { $this->removeAllCssClasses(); } }
public static function getSettings() { global $current_user; if (self::$settings === null) { if (function_exists('get_currentuserinfo')) { get_currentuserinfo(); /** @var $settings - get use group access rules */ if (!empty($current_user->roles)) { self::$user_role = $current_user->roles[0]; } else { self::$user_role = 'author'; } } else { self::$user_role = 'author'; } self::$settings = WPBakeryVisualComposerSettings::get('groups_access_rules'); } return self::$settings; }
public function output($post = null) { global $current_user; get_currentuserinfo(); /** @var $settings - get use group access rules */ $settings = WPBakeryVisualComposerSettings::get('groups_access_rules'); $role = $current_user->roles[0]; $show_role = isset($settings[$role]['show']) ? $settings[$role]['show'] : ''; $buttons = $this->buildButtons(); $output = ' <div id="wpb_visual_composer-elements" class="vc_navbar"> <input type="hidden" name="wpb_js_composer_group_access_show_rule" class="wpb_js_composer_group_access_show_rule" value="' . $show_role . '" /> <div class="vc_navbar-inner clearfix"> <!--<div class="container">--> <ul class="vc_nav"> <li> <a title="' . __('Visual Composer for WordPress', LANGUAGE_ZONE) . '" href="http://vc.wpbakery.com/" class="vc_logo" target="_blank"></a> </li> </ul> ' . $buttons . ' <!--</div>--> </div> </div>'; return $output; }
function get_custom_column_class($class) { $custom_array = (array) WPBakeryVisualComposerSettings::get('column_css_classes'); return !empty($custom_array[$class]) ? $custom_array[$class] : ''; }
/** * Create shortcode's string. * * @since 3.0 * @access public * @deprecated */ public function elementBackendHtml() { global $current_user; get_currentuserinfo(); $data_element = vc_post_param( 'data_element' ); /** @xvar $settings - get use group access rules */ $settings = WPBakeryVisualComposerSettings::get( 'groups_access_rules' ); $role = $current_user->roles[0]; if ( $data_element == 'vc_column' && vc_post_param( 'data_width' ) !== null ) { $output = do_shortcode( '[vc_column width="' . vc_post_param( 'data_width' ) . '"]' ); echo $output; } elseif ( $data_element == 'vc_row' || $data_element == 'vc_row_inner' ) { $output = do_shortcode( '[' . $data_element . ']' ); echo $output; } elseif ( ! isset( $settings[$role]['shortcodes'] ) || ( isset( $settings[$role]['shortcodes'][$data_element] ) && (int)$settings[$role]['shortcodes'][$data_element] == 1 ) ) { $output = do_shortcode( '[' . $data_element . ']' ); echo $output; } die(); }
/** * Create shortcode's string. * * @since 3.0 * @access public * @deprecated */ public function elementBackendHtml() { global $current_user; get_currentuserinfo(); if (!vc_verify_admin_nonce() || !current_user_can('edit_posts') && !current_user_can('edit_pages')) { wp_send_json(array('success' => false)); } $data_element = vc_post_param('data_element'); /** @var $settings - get use group access rules */ $settings = WPBakeryVisualComposerSettings::get('groups_access_rules'); $role = $current_user->roles[0]; if ($data_element === 'vc_column' && vc_post_param('data_width') !== null) { $output = do_shortcode('[vc_column width="' . vc_post_param('data_width') . '"]'); echo $output; } elseif ($data_element == 'vc_row' || $data_element == 'vc_row_inner' || $data_element == 'mk_page_section') { $output = do_shortcode('[' . $data_element . ']'); echo $output; } elseif (!isset($settings[$role]['shortcodes']) || isset($settings[$role]['shortcodes'][$data_element]) && (int) $settings[$role]['shortcodes'][$data_element] === 1) { $output = do_shortcode('[' . $data_element . ']'); echo $output; } die; }
public function removeSettingsNotificationJavascript_callback() { WPBakeryVisualComposerSettings::removeNotification(); }
public function output($post = null) { global $current_user; get_currentuserinfo(); /** @var $settings - get use group access rules */ $settings = WPBakeryVisualComposerSettings::get('groups_access_rules'); $role = $current_user->roles[0]; $show_role = isset($settings[$role]['show']) ? $settings[$role]['show'] : ''; $output = ' <div id="wpb_visual_composer-elements" class="navbar"> <input type="hidden" name="wpb_js_composer_group_access_show_rule" class="wpb_js_composer_group_access_show_rule" value="' . $show_role . '" /> <div class="navbar-inner"> <div class="container"> <a title="' . __('Visual Composer for WordPress', 'js_composer') . '" href="http://wpbakery.com/vc/" class="brand" target="_blank"></a> <div class="nav-collapse"> <ul class="nav"> <li class="dropdown wpb_deprecated_element"> <a data-toggle="dropdown" class="dropdown-toggle wpb_popular_layouts" href="#">' . __("Popular Layouts", "js_composer") . ' <b class="caret"></b></a> <ul class="dropdown-menu"> ' . $this->getColumnLayouts() . ' </ul> </li> <li class="dropdown wpb_deprecated_element"> <a data-toggle="dropdown" class="dropdown-toggle wpb_content_elements" href="#">' . __("Content Elements", "js_composer") . ' <b class="caret"></b></a> <ul class="dropdown-menu wpb-content-layouts-container"> ' . $this->getContentCategoriesLayouts() . ' ' . $this->getContentLayouts() . ' </ul> </li> <li> <a class="wpb_add_new_element dropable_el button" id="wpb-add-new-element"><i class="icon"></i>' . __('Add element', 'js_composer') . '</a> </li> </ul> <ul class="nav"><li> <a class="wpb_add_new_row dropable_row button" id="wpb-add-new-row" data-element="vc_row"><i class="icon"></i>' . __('Add row', 'js_composer') . '</a> </li></ul> <ul class="nav"> <li class="dropdown"> <a data-toggle="dropdown" class="wpb_templates button" href="#"><i class="icon"></i>' . __('Templates', 'js_composer') . ' <b class="caret"></b></a> <ul class="dropdown-menu wpb_templates_ul"> ' . $this->getTemplateMenu() . ' </ul> </li> </ul> <ul class="nav pull-right wpb-update-button"> <li><a class="button" id="wpb-save-post">' . __('Update', 'jscomposer') . '</a></li> </ul> </div><!-- /.nav-collapse --> </div> </div> </div> <style type="text/css">#wpb_visual_composer {display: none;}</style>'; return $output; }
/** * Adds themes css class to body tag. * @param $classes * @return array */ public function addThemeBodyClass($classes) { if (!class_exists('WPBakeryVisualComposerSettings')) { return $classes; } $theme = ($theme = get_option(WPBakeryVisualComposerSettings::getFieldPrefix() . 'themes')) ? $theme : ''; if (!empty($theme)) { $classes[] = 'vct_' . preg_replace('/\\.css$/', '', $theme); } return $classes; }
function showButton($post_id = null) { global $current_user; get_currentuserinfo(); $show = true; if (!self::inlineEnabled() || !current_user_can('edit_post', $post_id)) { return false; } /** @var $settings - get use group access rules */ $settings = WPBakeryVisualComposerSettings::get('groups_access_rules'); foreach ($current_user->roles as $role) { if (isset($settings[$role]['show']) && $settings[$role]['show'] === 'no') { $show = false; break; } } return $show && in_array(get_post_type(), $this->composer->getPostTypes()); }
public function setUpPlugin() { global $current_user; get_currentuserinfo(); /** @var $settings - get use group access rules */ $settings = WPBakeryVisualComposerSettings::get('groups_access_rules'); parent::setUpPlugin(); $show = true; foreach ($current_user->roles as $role) { if (isset($settings[$role]['show']) && $settings[$role]['show'] === 'no') { $show = false; break; } } if ($show) { $this->composer->addAction('edit_post', 'saveMetaBoxes'); $this->composer->addAction('wp_ajax_wpb_get_element_backend_html', 'elementBackendHtmlJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_get_convert_elements_backend_html', 'Convert2NewVersionJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_get_row_element_backend_html', 'elementRowBackendHtmlJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_shortcodes_to_visualComposer', 'shortCodesVisualComposerJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_show_edit_form', 'showEditFormJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_save_template', 'saveTemplateJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_load_template', 'loadTemplateJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_delete_template', 'deleteTemplateJavascript_callback'); $this->addAction('admin_init', 'jsComposerEditPage', 5); } // Add specific CSS class by filter $this->addFilter('body_class', 'jsComposerBodyClass'); $this->addFilter('get_media_item_args', 'jsForceSend'); $this->addAction('admin_init', 'composerRedirect'); $this->addAction('admin_init', 'registerCss'); $this->addAction('admin_init', 'registerJavascript'); $this->addAction('admin_menu', 'composerSettings'); $this->addAction('admin_print_scripts-post.php', 'editScreen_js'); $this->addAction('admin_print_scripts-post-new.php', 'editScreen_js'); /* Create Media tab for images */ $this->composer->createImagesMediaTab(); }
<ul class="nav navbar-nav navbar-right"> <li class="line"></li> <li><a id="vc-post-settings-button" class="vc_post_settings" title="<?php esc_attr_e('Page settings', LANGUAGE_ZONE); ?> "><i class="icon"></i></a></li> <li class="line"></li> <li><button id="vc-guides-toggle-button" class="btn-primary btn navbar-btn btn-sm vc_guides_toggle" title="<?php esc_attr_e("Toggle editor's guides", LANGUAGE_ZONE); ?> "><?php _e('Guides ON', LANGUAGE_ZONE); ?> </button></li> <?php $disable_responsive = WPBakeryVisualComposerSettings::get('not_responsive_css'); if ($disable_responsive !== '1') { ?> <li class="line"></li> <li> <div class="vc-dropdown" id="vc-screen-size-control"> <a href="#" class="vc-dropdown-toggle" title="<?php _e("Responsive preview", LANGUAGE_ZONE); ?> "><i class="icon default" id="vc-screen-size-current"></i><b class="caret"></b></a> <ul class="vc-dropdown-list"> <li><a href="#" title="<?php esc_attr_e('Desktop', LANGUAGE_ZONE); ?> " class="vc-screen-width active default" data-size="100%"></a></li> <li><a href="#" title="<?php
public function elementRowBackendHtmlJavascript_callback() { global $current_user; get_currentuserinfo(); $data_element = $this->post('data_element'); $data_width = $this->post('data_width'); /** @var $settings - get use group access rules */ $settings = WPBakeryVisualComposerSettings::get('groups_access_rules'); $role = $current_user->roles[0]; if ($data_element == 'vc_column') { $output = do_shortcode('[vc_row][vc_column width="' . ($data_width ? $data_width : '1/1') . '"][/vc_row]'); echo $output; } elseif (!isset($settings[$role]['shortcodes']) || isset($settings[$role]['shortcodes'][$data_element]) && (int) $settings[$role]['shortcodes'][$data_element] == 1) { $output = do_shortcode('[vc_row][vc_column width="1/1"][' . $data_element . '][/vc_column][/vc_row]'); echo $output; } die; }
public function activateLicense() { $params = array(); $params['username'] = $this->post('username'); $params['key'] = $this->post('key'); $params['api_key'] = $this->post('api_key'); $params['url'] = get_site_url(); $params['ip'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''; $params['dkey'] = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20); $string = 'activatelicense?'; $request_url = self::getWpbControlUrl(array($string, http_build_query($params, '', '&'))); $response = wp_remote_get($request_url, array('timeout' => 300)); if (is_wp_error($response)) { echo json_encode(array('result' => false)); die; } $result = json_decode($response['body']); if (!is_object($result)) { echo json_encode(array('result' => false)); die; } if ((bool) $result->result === true || (int) $result->code === 401 && isset($result->deactivation_key)) { $this->setDeactivationLicense(isset($result->code) && (int) $result->code === 401 ? $result->deactivation_key : $params['dkey']); update_option(WPBakeryVisualComposerSettings::getFieldPrefix() . 'envato_username', $params['username']); update_option(WPBakeryVisualComposerSettings::getFieldPrefix() . 'envato_api_key', $params['api_key']); update_option(WPBakeryVisualComposerSettings::getFieldPrefix() . 'js_composer_purchase_code', $params['key']); echo json_encode(array('result' => true)); die; } echo $response['body']; die; }
public function setUpPlugin() { global $current_user; get_currentuserinfo(); /** @var $settings - get use group access rules */ $settings = WPBakeryVisualComposerSettings::get('groups_access_rules'); parent::setUpPlugin(); $show = true; foreach ($current_user->roles as $role) { if (isset($settings[$role]['show']) && $settings[$role]['show'] === 'no') { $show = false; break; } } if ($show) { $this->composer->addAction('edit_post', 'saveMetaBoxes'); $this->composer->addAction('wp_ajax_wpb_get_element_backend_html', 'elementBackendHtmlJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_get_convert_elements_backend_html', 'Convert2NewVersionJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_get_row_element_backend_html', 'elementRowBackendHtmlJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_shortcodes_to_visualComposer', 'shortCodesVisualComposerJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_single_image_src', 'singleImageSrcJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_gallery_html', 'galleryHTMLJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_get_loop_suggestion', 'getLoopSuggestionJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_remove_settings_notification_element_css_class', 'removeSettingsNotificationJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_image_url', 'getImageUrlByIdJavascript_callback'); /* * Create edit form html * @deprecated */ $this->composer->addAction('wp_ajax_wpb_show_edit_form', 'showEditFormJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_get_edit_form', 'getEditFormJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_save_template', 'saveTemplateJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_load_template', 'loadTemplateJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_load_template_shortcodes', 'loadTemplateShortcodesJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_delete_template', 'deleteTemplateJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_get_loop_settings', 'getLoopSettingsJavascript_callback'); $this->composer->addAction('wp_ajax_wpb_activate_license', 'activateLicense'); $this->composer->addAction('wp_ajax_wpb_deactivate_license', 'deactivateLicense'); $this->addAction('admin_init', 'jsComposerEditPage', 5); } // Add specific CSS class by filter $this->addFilter('body_class', 'jsComposerBodyClass'); $this->addFilter('get_media_item_args', 'jsForceSend'); $this->addAction('admin_init', 'composerRedirect'); $this->addAction('admin_init', 'registerCss'); $this->addAction('admin_init', 'registerJavascript'); if ($this->composer->isNetworkPlugin() && is_network_admin()) { $this->addAction('network_admin_menu', 'composerSettings'); } $this->addAction('admin_menu', 'composerSettings'); $this->addAction('admin_print_scripts-post.php', 'editScreen_js'); $this->addAction('admin_print_scripts-post-new.php', 'editScreen_js'); // Upgrade message in plugins list. if ($this->composer->updaterDisabled()) { return $this; } $plugin_file_name = 'js_composer/js_composer.php'; new WpbAutoUpdate(WPB_VC_VERSION, 'http://wpbakery.com/version/?' . time(), $plugin_file_name); $this->addAction('in_plugin_update_message-' . $plugin_file_name, 'addUpgradeMessageLink'); }
public function output($post = null) { global $current_user; get_currentuserinfo(); /** @var $settings - get use group access rules */ $settings = WPBakeryVisualComposerSettings::get('groups_access_rules'); $role = $current_user->roles[0]; $show_role = isset($settings[$role]['show']) ? $settings[$role]['show'] : ''; $buttons = $this->buildButtons(); $output = ' <div id="wpb_visual_composer-elements" class="vc_navbar"> <input type="hidden" name="wpb_js_composer_group_access_show_rule" class="wpb_js_composer_group_access_show_rule" value="' . $show_role . '" /> <div class="vc_navbar-inner clearfix"> <!--<div class="container">--> ' . $buttons . ' <ul class="vc_nav pull-right wpb-update-button"> <li><a class="button" id="wpb-save-post">' . __('Update', 'js_composer') . '</a></li> </ul> <!--</div>--> </div> </div>'; return $output; }