/** * Set redirect transition on update or activation * @since 4.5 */ function vc_page_welcome_set_redirect() { if (!is_network_admin() && !vc_get_param('activate-multi')) { /* nectar addition */ //set_transient( '_vc_page_welcome_redirect', 1, 30 ); /* nectar addition end */ } }
public function addMenuPageHooks() { if ( current_user_can( 'manage_options' ) ) { add_action( 'admin_menu', array( &$this, 'addMenuPage' ) ); add_action( 'network_admin_menu', array( &$this, 'addMenuPage' ) ); if(vc_get_param('page') === 'vc_settings' || vc_post_param('action') === 'update') { add_action( 'admin_init', array( $this, 'initAdmin' ) ); } } add_action( 'wp_ajax_wpb_remove_settings_notification_element_css_class', array( &$this, 'removeNotification' ) ); }
/** * */ function setPost() { global $post; $this->post = get_post(); // fixes #1342 if no get/post params set $this->post_id = vc_get_param('post_id'); if (vc_post_param('post_id')) { $this->post_id = vc_post_param('post_id'); } if ($this->post_id) { $this->post = get_post($this->post_id); } do_action_ref_array('the_post', array(&$this->post)); $post = $this->post; $this->post_id = $this->post->ID; }
/** * Set VC mode. * * Mode depends on which page is requested by client from server and request parameters like vc_action. * * @since 4.2 * @access protected * @return void */ protected function setMode() { if (is_admin()) { if (vc_action() === 'vc_inline') { $this->mode = 'admin_frontend_editor'; } elseif (vc_action() === 'vc_upgrade' || vc_get_param('action') === 'update-selected' && vc_get_param('plugins') === $this->pluginName()) { $this->mode = 'admin_updater'; } elseif (isset($_GET['page']) && $_GET['page'] === $this->settings()->page()) { $this->mode = 'admin_settings_page'; } else { $this->mode = 'admin_page'; } } else { if (isset($_GET['vc_editable']) && $_GET['vc_editable'] === 'true') { $this->mode = 'page_editable'; } else { $this->mode = 'page'; } } }
/** * Set VC mode. * * Mode depends on which page is requested by client from server and request parameters like vc_action. * * @since 4.2 * @access protected * * @return void */ protected function setMode() { /** * @todo: Create another system (When ajax rebuild). * Use vc_action param to define mode. * 1. admin_frontend_editor - set by editor or request param * 2. admin_backend_editor - set by editor or request param * 3. admin_frontend_editor_ajax - set by request param * 4. admin_backend_editor_ajax - set by request param * 5. admin_updater - by vc_action * 6. page_editable - by vc_action */ if (is_admin()) { if (vc_action() === 'vc_inline') { $this->mode = 'admin_frontend_editor'; } elseif (vc_action() === 'vc_upgrade' || vc_get_param('action') === 'update-selected' && vc_get_param('plugins') === $this->pluginName()) { $this->mode = 'admin_updater'; } elseif (isset($_GET['page']) && $_GET['page'] === $this->settings()->page()) { $this->mode = 'admin_settings_page'; } else { $this->mode = 'admin_page'; } } else { if (isset($_GET['vc_editable']) && $_GET['vc_editable'] === 'true') { $this->mode = 'page_editable'; } else { $this->mode = 'page'; } } }
} $tabs = $new; } else { $tabs['vc-roles'] = __('Roles Manager', 'js_composer'); } return $tabs; } add_filter('vc_settings_tabs', 'vc_settings_tabs_vc_roles'); function vc_settings_render_tab_vc_roles() { return 'pages/vc-settings/tab-vc-roles.php'; } add_filter('vc_settings-render-tab-vc-roles', 'vc_settings_render_tab_vc_roles'); function vc_roles_settings_save() { if (check_admin_referer('vc_settings-roles-action', 'vc_nonce_field') && current_user_can('manage_options')) { require_once vc_path_dir('SETTINGS_DIR', 'class-vc-roles.php'); $vc_roles = new Vc_Roles(); $data = $vc_roles->save(vc_request_param('vc_roles', array())); echo json_encode($data); die; } } add_action('wp_ajax_vc_roles_settings_save', 'vc_roles_settings_save'); if ('vc-roles' == vc_get_param('page')) { function vc_settings_render_tab_vc_roles_scripts() { wp_register_script('vc_settings-roles-tab-js', vc_asset_url('js/lib/vc-roles-tab.js'), array('jquery'), WPB_VC_VERSION, true); } add_action('admin_init', 'vc_settings_render_tab_vc_roles_scripts'); }
/** * Set VC mode. * * Mode depends on which page is requested by client from server and request parameters like vc_action. * * @since 4.2 * @access protected * * @return void */ protected function setMode() { /** * TODO: Create another system (When ajax rebuild). * Use vc_action param to define mode. * 1. admin_frontend_editor - set by editor or request param * 2. admin_backend_editor - set by editor or request param * 3. admin_frontend_editor_ajax - set by request param * 4. admin_backend_editor_ajax - set by request param * 5. admin_updater - by vc_action * 6. page_editable - by vc_action */ if ( is_admin() ) { if ( vc_action() === 'vc_inline' && ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) ) { $this->mode = 'admin_frontend_editor'; } elseif ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && ( vc_action() === 'vc_upgrade' || ( vc_get_param( 'action' ) === 'update-selected' && vc_get_param( 'plugins' ) === $this->pluginName() ) ) ) { $this->mode = 'admin_updater'; } elseif ( current_user_can( 'manage_options' ) && isset( $_GET['page'] ) && $_GET['page'] === $this->settings()->page() ) { $this->mode = 'admin_settings_page'; } else { $this->mode = 'admin_page'; } } else { if ( vc_verify_admin_nonce() && current_user_can( 'edit_post', (int) vc_request_param( 'vc_post_id' ) ) && isset( $_GET['vc_editable'] ) && 'true' === $_GET['vc_editable'] ) { $this->mode = 'page_editable'; } else { $this->mode = 'page'; } } }
/** * @since 4.2 * @return bool */ function vc_is_frontend_ajax() { return 'true' === vc_post_param('vc_inline') || vc_get_param('vc_inline'); }
/** @var $editor Vc_Backend_Editor */ ?> <style> #wpb_visual_composer { display: none; } </style> <div class="metabox-composer-content"> <div id="visual_composer_content" class="wpb_main_sortable main_wrapper"></div> <?php require vc_path_dir('TEMPLATES_DIR', 'editors/partials/vc_welcome_block.tpl.php'); ?> </div> <?php $wpb_vc_status = apply_filters('wpb_vc_js_status_filter', vc_get_param('wpb_vc_js_status', get_post_meta($post->ID, '_wpb_vc_js_status', true))); if ('' === $wpb_vc_status || !isset($wpb_vc_status)) { $wpb_vc_status = vc_user_access()->part('backend_editor')->checkState('default')->get() ? 'true' : 'false'; } ?> <input type="hidden" id="wpb_vc_js_status" name="wpb_vc_js_status" value="<?php echo esc_attr($wpb_vc_status); ?> "/> <input type="hidden" id="wpb_vc_loading" name="wpb_vc_loading" value="<?php esc_attr_e('Loading, please wait...', 'js_composer'); ?> "/> <input type="hidden" id="wpb_vc_loading_row" name="wpb_vc_loading_row"
/** * Set redirect transition on update or activation * @since 4.5 */ function vc_page_welcome_set_redirect() { if (!is_network_admin() && !vc_get_param('activate-multi')) { set_transient('_vc_page_welcome_redirect', 1, 30); } }
function vc_page_settings_render() { $page = vc_get_param('page'); do_action('vc_page_settings_render-' . $page); vc_settings()->renderTab($page); }
<?php if (!defined('ABSPATH')) { die('-1'); } /** * Build and enqueue js/css for automapper settings tab. * @since 4.5 */ function vc_automapper_init() { if (vc_user_access()->wpAny('manage_options')->part('settings')->can('vc-automapper-tab')->get()) { vc_automapper()->addAjaxActions(); } } /** * Returns automapper template. * * @since 4.5 * @return string */ function vc_page_automapper_build() { return 'pages/vc-settings/vc-automapper.php'; } // TODO: move to separate file in autoload add_filter('vc_settings-render-tab-vc-automapper', 'vc_page_automapper_build'); is_admin() && ('vc_automapper' === vc_request_param('action') || 'vc-automapper' === vc_get_param('page')) && add_action('admin_init', 'vc_automapper_init');
public function output($post = null) { $output = $this->getNavBar()->getElementsModal(); $output .= $this->getNavBar()->output(); $output .= ' <div class="metabox-composer-content"> <div class="vc_loading_block" style="display: none;"> <img src="' . get_site_url() . '/wp-admin/images/wpspin_light.gif" /> ' . __("Loading, please wait...", "js_composer") . ' </div> <div id="visual_composer_content" class="wpb_main_sortable main_wrapper"></div> <div id="wpb-empty-blocks"> <h2>' . __("No content yet! You should add some...", "js_composer") . '</h2> <table class="helper-block"> <tr> <td><span>1</span></td> <td><p> ' . __("This is a visual preview of your page. Currently, you don't have any content elements. Click or drag the button <a href='#' class='add-element-to-layout'><i class='icon'></i> Add element</a> on the top to add content elements on your page. Alternatively add <a href='#' class='add-text-block-to-content' parent-container='#visual_composer_content'><i class='icon'></i> Text block</a> with single click.", "js_composer") . '</p></td> </tr> </table> <table class="helper-block"> <tr> <td><span>2</span></td><td><p class="one-line"> ' . __("Click the pencil icon on the content elements to change their properties.", "js_composer") . '</p></td> </tr> <tr> <td colspan="2"> <div class="edit-picture"></div> </td> </tr> </table> </div> </div> <div id="container-helper-block" style="display: none;">' . $this->getContainerHelper() . '</div>'; ?> <script type="text/javascript"> var vc_user_mapper = <?php echo json_encode(WPBMap::getUserShortCodes()); ?> , vc_mapper = <?php echo json_encode(WPBMap::getShortCodes()); ?> , vc_frontend_enabled = <?php echo vc_enabled_frontend() ? 'true' : 'false'; ?> ; </script> <?php $wpb_vc_status = apply_filters('wpb_vc_js_status_filter', vc_get_param('wpb_vc_js_status', get_post_meta($post->ID, '_wpb_vc_js_status', true))); $wpb_post_custom_css = get_post_meta($post->ID, '_wpb_post_custom_css', true); if ($wpb_vc_status == "" || !isset($wpb_vc_status)) { $wpb_vc_status = 'false'; } $output .= '<input type="hidden" id="wpb_custom_post_css_field" name="wpb_vc_post_custom_css" value="' . htmlspecialchars($wpb_post_custom_css) . '" />'; $output .= '<input type="hidden" id="wpb_vc_js_status" name="wpb_vc_js_status" value="' . $wpb_vc_status . '" />'; $output .= '<input type="hidden" id="wpb_vc_loading" name="wpb_vc_loading" value="' . __("Loading, please wait...", "js_composer") . '" />'; $output .= '<input type="hidden" id="wpb_vc_loading_row" name="wpb_vc_loading_row" value="' . __("Crunching...", "js_composer") . '" />'; $output .= '<input type="hidden" id="wpb_vc_js_interface_version" name="wpb_vc_js_interface_version" value="' . vc_get_initerface_version() . '" />'; echo $output; require_once vc_path_dir('TEMPLATES_DIR', 'backend_editor/templates.php'); do_action('vc_backend_editor_render'); }
/** * @since 4.3 */ public function vcFrontendEditorRender() { global $q_config; $output = ''; $q_lang = vc_get_param('qlang'); if (!is_string($q_lang)) { $q_lang = $q_config['language']; } $output .= '<input type="hidden" id="vc_vendor_qtranslate_postcontent" value="' . esc_attr(vc_frontend_editor()->post()->post_content) . '" data-lang="' . $q_lang . '"/>'; $output .= '<input type="hidden" id="vc_vendor_qtranslate_posttitle" value="' . esc_attr(vc_frontend_editor()->post()->post_title) . '" data-lang="' . $q_lang . '"/>'; echo $output; }
/** * Get link to newest VC * * @param $reply * @param $package * @param $updater * * @return mixed|string|WP_Error */ public function preUpgradeFilter($reply, $package, $updater) { $condition1 = isset($updater->skin->plugin) && $updater->skin->plugin === vc_plugin_name(); $condition2 = isset($updater->skin->plugin_info) && $updater->skin->plugin_info['Name'] === $this->title; if (!$condition1 && !$condition2) { return $reply; } $res = $updater->fs_connect(array(WP_CONTENT_DIR)); if (!$res) { return new WP_Error('no_credentials', __("Error! Can't connect to filesystem", 'js_composer')); } $license_key = vc_license()->getLicenseKey(); if (!$license_key || !vc_license()->isActivated()) { if (vc_is_as_theme() && vc_get_param('action') !== 'update-selected') { return false; } $url = esc_url(vc_is_network_plugin() ? network_admin_url('admin.php?page=vc-updater') : admin_url('admin.php?page=vc-updater')); return new WP_Error('no_credentials', __('To receive automatic updates license activation is required. Please visit <a href="' . $url . '' . '" target="_blank">Settings</a> to activate your Visual Composer.', 'js_composer') . ' ' . sprintf(' <a href="http://go.wpbakery.com/faq-update-in-theme" target="_blank">%s</a>', __('Got Visual Composer in theme?', 'js_composer'))); } $updater->strings['downloading_package_url'] = __('Getting download link...', 'js_composer'); $updater->skin->feedback('downloading_package_url'); $response = $this->getDownloadUrl($license_key); if (!$response) { return new WP_Error('no_credentials', __('Download link could not be retrieved', 'js_composer')); } if (!$response['status']) { return new WP_Error('no_credentials', $response['error']); } $updater->strings['downloading_package'] = __('Downloading package...', 'js_composer'); $updater->skin->feedback('downloading_package'); $downloaded_archive = download_url($response['url']); if (is_wp_error($downloaded_archive)) { return $downloaded_archive; } $plugin_directory_name = 'js_composer'; // WP will use same name for plugin directory as archive name, so we have to rename it if (basename($downloaded_archive, '.zip') !== $plugin_directory_name) { $new_archive_name = dirname($downloaded_archive) . '/' . $plugin_directory_name . '.zip'; rename($downloaded_archive, $new_archive_name); $downloaded_archive = $new_archive_name; } return $downloaded_archive; }
function buildEditForm() { $element = vc_get_param( 'element' ); $shortCode = stripslashes( vc_get_param( 'shortcode' ) ); WpbakeryShortcodeParams::setEnqueue( true ); $this->removeShortCode( $element ); $settings = WPBMap::getShortCode( $element ); new WPBakeryShortCode_Settings( $settings ); return do_shortcode( $shortCode ); }
<?php /** * Build and enqueue js/css for automapper settings tab. * @since 4.5 */ function vc_automapper_init() { vc_automapper()->build(); } /** * Returns automapper template. * * @since 4.5 * @return string */ function vc_page_automapper_build() { return 'pages/vc-settings/vc-automapper.php'; } // TODO: move to separate file in autoload add_filter('vc_settings-render-tab-vc-automapper', 'vc_page_automapper_build'); is_admin() && 'vc-automapper' === vc_get_param('page') && add_action('admin_enqueue_scripts', 'vc_automapper_init');
/** * Set VC mode. * * Mode depends on which page is requested by client from server and request parameters like vc_action. * * @since 4.2 * @access protected * * @return void */ protected function setMode() { /** * TODO: Create another system (When ajax rebuild). * Use vc_action param to define mode. * 1. admin_frontend_editor - set by editor or request param * 2. admin_backend_editor - set by editor or request param * 3. admin_frontend_editor_ajax - set by request param * 4. admin_backend_editor_ajax - set by request param * 5. admin_updater - by vc_action * 6. page_editable - by vc_action */ if (is_admin()) { if ('vc_inline' === vc_action()) { vc_user_access()->wpAny(array('edit_post', (int) vc_request_param('post_id')))->validateDie()->part('frontend_editor')->can()->validateDie(); $this->mode = 'admin_frontend_editor'; } elseif (vc_user_access()->wpAny('edit_posts', 'edit_pages')->get() && ('vc_upgrade' === vc_action() || 'update-selected' === vc_get_param('action') && $this->pluginName() === vc_get_param('plugins'))) { $this->mode = 'admin_updater'; } elseif (vc_user_access()->wpAny('manage_options')->get() && isset($_GET['page']) && $_GET['page'] === $this->settings()->page()) { $this->mode = 'admin_settings_page'; } else { $this->mode = 'admin_page'; } } else { if (isset($_GET['vc_editable']) && 'true' === $_GET['vc_editable']) { vc_user_access()->checkAdminNonce()->validateDie()->wpAny(array('edit_post', (int) vc_request_param('vc_post_id')))->validateDie()->part('frontend_editor')->can()->validateDie(); $this->mode = 'page_editable'; } else { $this->mode = 'page'; } } }
/** * @deprecated, @unused * Will be removed in v4.6 */ public function addMenuPageHooks() { if (current_user_can('manage_options')) { add_action('admin_menu', array(&$this, 'addMenuPage')); add_action('network_admin_menu', array(&$this, 'addMenuPage')); if (vc_get_param('page') === 'vc_settings' || vc_post_param('action') === 'update') { add_action('admin_init', array($this, 'initAdmin')); } } }