public function init() {
		$this->addHooks();
		/**
		 * If current mode of VC is frontend editor load it.
		 */
		if(vc_is_frontend_editor()) {
			vc_frontend_editor()->hookLoadEdit();
		} elseif(vc_mode() === 'page_editable') {
			/**
			 * if page loaded inside frontend editor iframe it has page_editable mode.
			 * It required to some some js/css elements and add few helpers for editor to be used.
			 */
			$this->buildEditablePage();
		} else {
			// Is it is simple page just enable buttons and controls
			$this->buildPage();
		}
	}
function vca_init()
{
    //  Labels
    $labels = array('name' => _x('VC Elements', 'post type general name', PLUGIN_VCA_TEXT_DOMAIN), 'singular_name' => _x('VC Element', 'post type singular name', PLUGIN_VCA_TEXT_DOMAIN), 'menu_name' => _x('VC Elements', 'admin menu', PLUGIN_VCA_TEXT_DOMAIN), 'name_admin_bar' => _x('VC Element', 'add new on admin bar', PLUGIN_VCA_TEXT_DOMAIN), 'add_new' => _x('Add New', 'vc element', PLUGIN_VCA_TEXT_DOMAIN), 'add_new_item' => __('Add New VC Element', PLUGIN_VCA_TEXT_DOMAIN), 'new_item' => __('New VC Element', PLUGIN_VCA_TEXT_DOMAIN), 'edit_item' => __('Edit VC Element', PLUGIN_VCA_TEXT_DOMAIN), 'view_item' => __('View VC Element', PLUGIN_VCA_TEXT_DOMAIN), 'all_items' => __('All VC Elements', PLUGIN_VCA_TEXT_DOMAIN), 'search_items' => __('Search VC Elements', PLUGIN_VCA_TEXT_DOMAIN), 'parent_item_colon' => __('Parent VC Elements:', PLUGIN_VCA_TEXT_DOMAIN), 'not_found' => __('No vc elements found.', PLUGIN_VCA_TEXT_DOMAIN), 'not_found_in_trash' => __('No vc elements found in Trash.', PLUGIN_VCA_TEXT_DOMAIN));
    //  Arguments
    $args = array('labels' => $labels, 'public' => false, 'publicly_queryable' => false, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => false, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title', 'editor'), 'register_meta_box_cb' => 'vca_register_meta_box_cb');
    //  Register the Post Type
    register_post_type(POST_TYPE_VC_ELEMENT, $args);
    //  Get the Post Type Options
    $ptOptions = get_option('wpb_js_content_types');
    //  Check
    if (!$ptOptions) {
        $ptOptions = array('page');
    }
    //  Assign
    $ptOptions = array_unique(array_merge($ptOptions, array(POST_TYPE_VC_ELEMENT)));
    //  Update Option
    update_option('wpb_js_content_types', $ptOptions);
    //  Get Page Now
    global $pagenow;
    //  Check for the VC Element Page
    if ($pagenow == 'edit.php' && @$_GET['post_type'] == POST_TYPE_VC_ELEMENT) {
        //  Remove the Filter
        remove_filter('post_row_actions', array(vc_frontend_editor(), 'renderRowAction'));
    }
}
 public function getControlFrontend()
 {
     if (!vc_enabled_frontend()) {
         return '';
     }
     return '<li class="vc_pull-right">' . '<a href="' . vc_frontend_editor()->getInlineUrl() . '" class="vc_btn vc_btn-primary vc_btn-sm vc_navbar-btn" id="wpb-edit-inline">' . __('Frontend', "js_composer") . '</a>' . '</li>';
 }
 /**
  * @return string
  */
 public function generateSelectFrontend()
 {
     global $q_config;
     $output = '';
     $output .= '<select id="vc_vendor_qtranslatex_langs_front" class="vc_select vc_select-navbar">';
     $inline_url = vc_frontend_editor()->getInlineUrl();
     $activeLanguage = $q_config['language'];
     $availableLanguages = $q_config['enabled_languages'];
     foreach ($availableLanguages as $lang) {
         $output .= '<option value="' . add_query_arg(array('lang' => $lang), $inline_url) . '"' . ($activeLanguage == $lang ? ' selected' : '') . ' > ' . qtranxf_getLanguageNameNative($lang) . '</option > ';
     }
     $output .= '</select > ';
     return $output;
 }
 /**
  * Used to render template for frontend
  * @since 4.4
  *
  * @param $template_id
  * @param $template_type
  *
  * @return string|int
  */
 public function renderFrontendTemplate($template_id, $template_type)
 {
     if (self::$template_type === $template_type) {
         WPBMap::addAllMappedShortcodes();
         // do something to return output of templatera template
         $post = get_post($template_id);
         if ($this->isSamePostType($post->post_type)) {
             vc_frontend_editor()->enqueueRequired();
             vc_frontend_editor()->setTemplateContent($post->post_content);
             vc_frontend_editor()->render('template');
             die;
         }
     }
     return $template_id;
 }
 /**
  *
  */
 public function init()
 {
     $this->addHooks();
     /**
      * If current mode of VC is frontend editor load it.
      */
     if (vc_is_frontend_editor()) {
         vc_frontend_editor()->hookLoadEdit();
     } elseif (vc_mode() === 'page_editable') {
         /**
          * if page loaded inside frontend editor iframe it has page_editable mode.
          * It required to some some js/css elements and add few helpers for editor to be used.
          */
         $this->buildEditablePage();
     } else {
         // Is it is simple page just enable buttons and controls
         $this->buildPage();
     }
     /**
      * Load required vendors classes;
      * @deprecated since 4.4 due to autoload logic
      */
     visual_composer()->vendorsManager()->load();
 }
 /**
  * @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;
 }
<?php

if (vc_frontend_editor()->inlineEnabled()) {
    vc_include_template('pages/partials/vc-roles-parts/_part.tpl.php', array('part' => $part, 'role' => $role, 'params_prefix' => 'vc_roles[' . $role . '][' . $part . ']', 'controller' => vc_role_access()->who($role)->part($part), 'custom_value' => 'custom', 'options' => array(array(true, __('Enabled', 'js_composer')), array(false, __('Disabled', 'js_composer'))), 'main_label' => __('Frontend editor', 'js_composer'), 'custom_label' => __('Frontend editor', 'js_composer')));
}
Example #9
0
 /**
  * Callback function for WP init action hook. Sets Vc mode and loads required objects.
  *
  * @since  4.2
  * @access public
  * @return void
  */
 public function init()
 {
     do_action('vc_before_init');
     $this->setMode();
     /**
      * Set version of VC if required.
      */
     $this->setVersion();
     // Load required
     !vc_is_updater_disabled() && vc_updater()->init();
     /**
      * Init default hooks and options to load.
      */
     $this->vc()->init();
     /**
      * if is admin and not front end editor.
      */
     is_admin() && !vc_is_frontend_editor() && $this->asAdmin();
     /**
      * if frontend editor is enabled init editor.
      */
     vc_enabled_frontend() && vc_frontend_editor()->init();
     // Load Automapper
     vc_automapper()->addAjaxActions();
     do_action('vc_before_mapping');
     // VC ACTION
     // Include default shortcodes.
     $this->mapper()->init();
     //execute all required
     do_action('vc_after_mapping');
     // VC ACTION
     // Load && Map shortcodes from Automapper.
     vc_automapper()->map();
     do_action('vc_after_init');
 }
Example #10
0
/**
 * New Vc now called Frontend editor
 * @deprecated 4.7
 * @return Vc_Frontend_Editor
 * @since 4.3
 */
function new_vc()
{
    // _deprecated_function( 'new_vc', '4.7 (will be removed in 4.10)', 'vc_frontend_editor' );
    return vc_frontend_editor();
}
 /**
  * Load frontend default template content by index
  */
 public function renderFrontendDefaultTemplate()
 {
     $template_index = vc_post_param('template_name');
     $data = $this->getDefaultTemplate($template_index);
     !$data && die('0');
     vc_frontend_editor()->setTemplateContent(trim($data['content']));
     vc_frontend_editor()->enqueueRequired();
     vc_include_template('editors/frontend_template.tpl.php', array('editor' => vc_frontend_editor()));
     die;
 }
 /**
  * Add custom css from shortcodes from template for template editor.
  *
  * Used by action 'wp_print_scripts'.
  *
  * @todo move to autoload or else some where.
  * @since 4.4.3
  *
  * @return string
  */
 public function addFrontendTemplatesShortcodesCustomCss()
 {
     $output = $shortcodes_custom_css = '';
     $shortcodes_custom_css = visual_composer()->parseShortcodesCustomCss(vc_frontend_editor()->getTemplateContent());
     if (!empty($shortcodes_custom_css)) {
         $output .= '<style type="text/css" data-type="vc_shortcodes-custom-css">';
         $output .= $shortcodes_custom_css;
         $output .= '</style>';
     }
     echo $output;
 }
 /**
  * Load frontend default template content by index
  * Used in Vc_Frontend_Editor::loadShortcodes action 'vc_frontend_default_template'
  * @deprecated 4.4 use action 'vc_frontend_default_template_panel' and
  *   Vc_Templates_Panel_Editor::renderFrontendDefaultTemplate
  */
 public function renderFrontendDefaultTemplate()
 {
     // _deprecated_function( 'Vc_Templates_Editor::renderMenu', '4.4 (will be removed in 4.11)', 'Vc_Templates_Panel_Editor::renderFrontendDefaultTemplat' );
     $template_index = vc_post_param('template_name');
     $data = $this->getDefaultTemplate($template_index);
     !$data && die('0');
     vc_frontend_editor()->setTemplateContent(trim($data['content']));
     vc_frontend_editor()->enqueueRequired();
     vc_include_template('editors/frontend_template.tpl.php', array('editor' => vc_frontend_editor()));
     die;
 }
Example #14
0
 public function vc_after_init()
 {
     //remove vc edit button from admin bar
     remove_action('admin_bar_menu', array(vc_frontend_editor(), 'adminBarEditLink'), 1000);
     //remove vc edit button from wp edit links
     remove_filter('edit_post_link', array(vc_frontend_editor(), 'renderEditButton'));
     //vc_disable_frontend(); // this will disable frontend editor
 }
 /**
  * Load frontend default template content by index
  * @since 4.4
  */
 public function renderFrontendDefaultTemplate()
 {
     $template_index = (int) vc_post_param('template_unique_id');
     $data = $this->getDefaultTemplate($template_index);
     if (!$data) {
         die('Error: Vc_Templates_Panel_Editor::renderFrontendDefaultTemplate:1');
     }
     vc_frontend_editor()->setTemplateContent(trim($data['content']));
     vc_frontend_editor()->enqueueRequired();
     vc_include_template('editors/frontend_template.tpl.php', array('editor' => vc_frontend_editor()));
     die;
 }
Example #16
0
/**
 * New Vc now called Frontend editor
 * @deprecated 4.7
 * @return Vc_Frontend_Editor
 * @since 4.3
 */
function new_vc()
{
    _deprecated_function('new_vc', '4.7', 'vc_frontend_editor');
    return vc_frontend_editor();
}
Example #17
0
function vc_remove_wp_admin_bar_button()
{
    remove_action('admin_bar_menu', array(vc_frontend_editor(), 'adminBarEditLink'), 1000);
}
 /**
  * Used to render template for frontend
  * @since 4.4
  *
  * @param $template_id
  * @param $template_type
  *
  * @return string|int
  */
 public function renderFrontendTemplate($template_id, $template_type)
 {
     if ($template_type == 'templatera_templates') {
         // do something to return output of templatera template
         $post = get_post($template_id);
         if ($post->post_type == self::$post_type) {
             set_vc_is_inline();
             // todo make sure we need this?
             vc_frontend_editor()->enqueueRequired();
             vc_frontend_editor()->setTemplateContent($post->post_content);
             vc_frontend_editor()->render('template');
             die;
         }
     }
     return $template_id;
 }
 /**
  * Get template content for frontend.
  * @deprecated since 4.4 we use VcTemplateManager::renderBackendTemplate and VcTemplateManager::renderFrontendTemplate
  */
 public function loadInline()
 {
     $post = !empty($_POST['template_id']) ? get_post($_POST['template_id']) : false;
     if (!$post || $post->post_type !== self::$post_type) {
         die;
     }
     set_vc_is_inline();
     vc_frontend_editor()->enqueueRequired();
     vc_frontend_editor()->setTemplateContent($post->post_content);
     vc_frontend_editor()->render('template');
     die;
 }
Example #20
0
/**
 * Check is front end enabled.
 * @since 4.3
 * @return bool
 */
function vc_enabled_frontend()
{
    return vc_frontend_editor()->inlineEnabled();
}
Example #21
0
/**
 * Check is front end enabled.
 * @since 4.3
 * @return bool
 */
function vc_enabled_frontend()
{
    return vc_frontend_editor()->frontendEditorEnabled();
}
Example #22
0
 function buildButtons()
 {
     $html = '';
     $buttons = array(array('add_element', '<ul class="vc_nav">
                             <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>'), array('add_row', '<ul class="vc_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>'), array('templates', '<ul class="vc_nav">
                             <li class="vc_dropdown">
                                 <a class="wpb_templates button"><i class="icon"></i>' . __('Templates', "js_composer") . ' <b class="caret"></b></a>
                                 <ul class="vc_dropdown-menu wpb_templates_ul">
                                     ' . $this->getTemplateMenu() . '
                                 </ul>
                             </li>
                         </ul>'), array('edit_inline', vc_enabled_frontend() ? '<ul class="vc_nav">
                           <li>
                             <a href="' . vc_frontend_editor()->getInlineUrl() . '" class="wpb_edit_inline dropable_row button" id="wpb-edit-inline"><i class="icon"></i>' . __('Frontend Edit', "js_composer") . '</a>
                             </li>
                         </ul>' : ''), array('update_button', '<ul class="vc_nav pull-right wpb-update-button">
                             <li><a class="button" id="wpb-save-post">' . __('Update', "js_composer") . '</a></li>
                         </ul>'), array('custom_css', '<ul class="vc_nav pull-right">
                     <li><a class="wpb_custom_post_css button" id="wpb-custom-post-css"><i class="icon"></i>' . __('CSS', "js_composer") . '</a></li>
             </ul> '));
     $buttons = apply_filters('vc_nav_controls', $buttons);
     foreach ($buttons as $button) {
         $html .= $button[1];
     }
     return $html;
 }
Example #23
0
 /**
  * Callback function for WP init action hook. Sets Vc mode and loads required objects.
  *
  * @since  4.2
  * @access public
  *
  * @return void
  */
 public function init()
 {
     do_action('vc_before_init');
     $this->setMode();
     do_action('vc_after_set_mode');
     /**
      * Set version of VC if required.
      */
     $this->setVersion();
     // Load required
     !vc_is_updater_disabled() && vc_updater()->init();
     /**
      * Init default hooks and options to load.
      */
     $this->vc()->init();
     /**
      * if is admin and not front end editor.
      */
     is_admin() && !vc_is_frontend_editor() && $this->asAdmin();
     /**
      * if frontend editor is enabled init editor.
      */
     vc_enabled_frontend() && vc_frontend_editor()->init();
     do_action('vc_before_mapping');
     // VC ACTION
     // Include default shortcodes.
     $this->mapper()->init();
     //execute all required
     do_action('vc_after_mapping');
     // VC ACTION
     // Load && Map shortcodes from Automapper.
     vc_automapper()->map();
     if (vc_user_access()->wpAny('manage_options')->part('settings')->can('vc-updater-tab')->get()) {
         vc_license()->setupReminder();
     }
     do_action('vc_after_init');
 }
	public function loadInline() {
		vc_frontend_editor()->getTemplateShortcodes();
		die();
	}