Beispiel #1
0
 /**
  *
  */
 public function setTabs()
 {
     $this->tabs = array();
     if ($this->showConfigurationTabs()) {
         $this->tabs['vc-general'] = __('General Settings', 'js_composer');
         if (!vc_is_as_theme() && apply_filters('vc_settings_page_show_design_tabs', true)) {
             $this->tabs['vc-color'] = __('Design Options', 'js_composer');
             $this->tabs['vc-custom_css'] = __('Custom CSS', 'js_composer');
         }
     }
     if (!vc_is_network_plugin() || vc_is_network_plugin() && is_network_admin()) {
         if (!vc_is_updater_disabled()) {
             $this->tabs['vc-updater'] = __('Product License', 'js_composer');
         }
     }
     // TODO: may allow to disable automapper
     if (!is_network_admin() && !vc_automapper_is_disabled()) {
         $this->tabs['vc-automapper'] = vc_automapper()->title();
     }
 }
Beispiel #2
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');
 }
Beispiel #3
0
    /**
     *  HTML template
     */
    public function output()
    {
        wp_enqueue_style('wp-color-picker');
        wp_enqueue_script('wp-color-picker');
        if (isset($_GET['build_css']) && ($_GET['build_css'] == '1' || $_GET['build_css'] == 'true') || isset($_GET['settings-updated']) && ($_GET['settings-updated'] === '1' || $_GET['settings-updated'] === 'true')) {
            $this->buildCustomColorCss();
            $this->buildCustomCss();
        }
        $use_custom = get_option(self::$field_prefix . 'use_custom');
        ?>
	<div class="wrap vc-settings" id="wpb-js-composer-settings">
		<h2><?php 
        _e('Visual Composer Settings', LANGUAGE_ZONE);
        ?>
</h2>
		<?php 
        ?>
		<h2 class="nav-tab-wrapper vc-settings-tabs">
			<?php 
        foreach ($this->tabs as $tab => $title) {
            ?>
			<a href="#vc-settings-<?php 
            echo $tab;
            ?>
"
			   class="vc-settings-tab-control nav-tab<?php 
            echo $this->active_tab == $tab ? ' nav-tab-active' : '';
            ?>
"><?php 
            echo $title;
            ?>
</a>
			<?php 
        }
        ?>
		</h2>
		<?php 
        foreach ($this->tabs as $tab => $title) {
            ?>
		<?php 
            if ($tab == 'element_css') {
                ?>
			<form action="options.php" method="post" id="vc-settings-<?php 
                echo $tab;
                ?>
"
				  class="vc-settings-tab-content<?php 
                echo $this->active_tab == $tab ? ' vc-settings-tab-content-active' : '';
                ?>
">
				<?php 
                settings_fields($this->option_group . '_' . $tab);
                ?>
				<div class="deprecated">
					<p>
						<?php 
                _e("<strong>Deprecated:</strong> To override class names that are applied to Visual Composer content elements you should use WordPress add_filter('vc_shortcodes_css_class') function. <a class='vc_show_example'>See Example</a>.", LANGUAGE_ZONE);
                ?>
					</p>
				</div>
				<div class="vc_helper">
					<?php 
                $row_css_class = ($value = get_option(self::$field_prefix . 'row_css_class')) ? $value : '';
                $column_css_classes = ($value = get_option(self::$field_prefix . 'column_css_classes')) ? (array) $value : array();
                if (!empty($row_css_class) || strlen(implode('', array_values($column_css_classes))) > 0) {
                    echo '<p>' . __('You have used element class names settings to replace row and column css classes.') . '</p>';
                    echo '<p>' . __('Below is code snippet which you should add to your functions.php file in your theme, to replace row and column classes with custom classes saved by you earlier.') . '</p>';
                    $function = <<<EOF
\t\t<?php
\t\tfunction custom_css_classes_for_vc_row_and_vc_column(\$class_string, \$tag) {
EOF;
                    if (!empty($row_css_class)) {
                        $function .= <<<EOF

\t\t\tif(\$tag=='vc_row' || \$tag=='vc_row_inner') {
\t\t\t\t\$class_string = str_replace('vc_row-fluid', '{$row_css_class}', \$class_string);
\t\t\t}
EOF;
                    }
                    $started_column_replace = false;
                    for ($i = 1; $i <= 12; $i++) {
                        if (!empty($column_css_classes['span' . $i])) {
                            if (!$started_column_replace) {
                                $started_column_replace = true;
                                $function .= <<<EOF

\t\t\tif(\$tag=='vc_column' || \$tag=='vc_column_inner') {

EOF;
                            }
                            $function .= <<<EOF
\t\t\t\t\$class_string = str_replace('vc_span{$i}', '{$column_css_classes['span' . $i]}', \$class_string);

EOF;
                        }
                    }
                    if ($started_column_replace) {
                        $function .= <<<EOF
\t\t\t}
EOF;
                    }
                    $function .= <<<EOF

\t\t\treturn \$class_string;
\t\t}
\t\t// Filter to Replace default css class for vc_row shortcode and vc_column
\t\tadd_filter('vc_shortcodes_css_class', 'custom_css_classes_for_vc_row_and_vc_column', 10, 2);
\t\t?>
EOF;
                    echo '<div class="vc_filter_function"><pre>' . htmlentities2($function) . '</pre></div>';
                } else {
                    $function = <<<EOF
\t\t<?php
\t\tfunction custom_css_classes_for_vc_row_and_vc_column(\$class_string, \$tag) {
\t\t\tif(\$tag=='vc_row' || \$tag=='vc_row_inner') {
\t\t\t\t\$class_string = str_replace('vc_row-fluid', 'my_row-fluid', \$class_string);
\t\t\t}
\t\t\tif(\$tag=='vc_column' || \$tag=='vc_column_inner') {
\t\t\t\t\$class_string = preg_replace('/vc_span(\\d{1,2})/', 'my_span\$1', \$class_string);
\t\t\t}
\t\t\treturn \$class_string;
\t\t}
\t\t// Filter to Replace default css class for vc_row shortcode and vc_column
\t\tadd_filter('vc_shortcodes_css_class', 'custom_css_classes_for_vc_row_and_vc_column', 10, 2);
\t\t?>
EOF;
                    echo '<div class="vc_filter_function"><pre>' . htmlentities2($function) . '</pre></div>';
                }
                ?>
				</div>
				<?php 
                settings_fields($this->option_group . '_' . $tab);
                ?>
				<?php 
                do_settings_sections($this->page . '_' . $tab);
                ?>
				<?php 
                wp_nonce_field('wpb_js_settings_save_action', 'wpb_js_nonce_field');
                ?>
				<input type="hidden" name="vc_action" value="" id="vc-settings-<?php 
                echo $tab;
                ?>
-action"/>
				<a href="#" class="button vc-restore-button"
				   id="vc-settings-custom-css-reset-data"><?php 
                _e('Remove all saved', LANGUAGE_ZONE);
                ?>
</a>
			</form>
			<?php 
            } elseif ($tab == 'automapper') {
                ?>
			<form action="options.php" method="post" id="vc-settings-<?php 
                echo $tab;
                ?>
"
				  class="vc-settings-tab-content<?php 
                echo $this->active_tab == $tab ? ' vc-settings-tab-content-active' : '';
                ?>
"<?php 
                echo apply_filters('vc_setting-tab-form-' . $tab, '');
                ?>
>
				<?php 
                vc_automapper()->renderHtml();
                ?>
			</form>
			<?php 
            } else {
                ?>
			<?php 
                $css = $tab == 'color' && $use_custom ? ' color_enabled' : '';
                ?>
			<form action="options.php" method="post" id="vc-settings-<?php 
                echo $tab;
                ?>
"
				  class="vc-settings-tab-content<?php 
                echo ($this->active_tab == $tab ? ' vc-settings-tab-content-active' : '') . $css;
                ?>
"<?php 
                echo apply_filters('vc_setting-tab-form-' . $tab, '');
                ?>
>
				<?php 
                settings_fields($this->option_group . '_' . $tab);
                ?>
				<?php 
                do_settings_sections($this->page . '_' . $tab);
                ?>
				<?php 
                wp_nonce_field('wpb_js_settings_save_action', 'wpb_js_nonce_field');
                ?>
				<?php 
                $submit_button_attributes = array();
                $license_activation_key = vc_license()->deactivation();
                if ($tab === 'updater' && !empty($license_activation_key)) {
                    $submit_button_attributes['disabled'] = 'true';
                }
                ?>
				<?php 
                submit_button(__('Save Changes', LANGUAGE_ZONE), 'primary', 'submit', true, $submit_button_attributes);
                ?>
				<input type="hidden" name="vc_action" value="" id="vc-settings-<?php 
                echo $tab;
                ?>
-action"/>
				<?php 
                if ($tab == 'color') {
                    ?>
				<a href="#" class="button vc-restore-button"
				   id="vc-settings-color-restore-default"><?php 
                    _e('Restore to defaults', LANGUAGE_ZONE);
                    ?>
</a>
				<?php 
                }
                ?>
				<?php 
                if ($tab === 'updater') {
                    ?>
				<input type="hidden" id="vc-settings-license-status" name="vc_license_status"
					   value="<?php 
                    echo empty($license_activation_key) ? 'not_activated' : 'activated';
                    ?>
"/>
				<a href="#" class="button vc-activate-license-button"
				   id="vc-settings-activate-license"><?php 
                    empty($license_activation_key) ? _e('Activate license', LANGUAGE_ZONE) : _e('Deactivate license', LANGUAGE_ZONE);
                    ?>
</a>
				<span class="vc-updater-spinner-wrapper" style="display: none;" id="vc-updater-spinner"><img
				  src="<?php 
                    echo get_site_url();
                    ?>
/wp-admin/images/wpspin_light.gif"/></span>
				<?php 
                }
                ?>
			</form>
			<?php 
            }
            ?>

		<?php 
        }
        ?>
	</div>
	<?php 
    }
/**
 * @since 4.2
 * @return bool
 */
function vc_automapper_is_disabled()
{
    return vc_automapper()->disabled();
}
Beispiel #5
0
 public function setUpPlugin()
 {
     if (is_plugin_active_for_network('js_composer/js_composer.php') || is_network_only_plugin('js_composer/js_composer.php')) {
         $this->composer->setAsNetworkPlugin(true);
     }
     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_inline_template', 'loadInlineTemplateJavascript_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->composer->inlineEditor()->addAction('wp_ajax_vc_load_shortcode', 'loadShortcodes');
         $this->composer->inlineEditor()->addAction('wp_ajax_vc_show_edit_form', 'renderEditForm');
         $this->composer->inlineEditor()->addAction('wp_ajax_vc_update_content', 'savePost');
         $this->composer->inlineEditor()->addAction('wp_ajax_vc_inline_template', 'renderTemplate');
         $this->composer->inlineEditor()->addAction('wp_ajax_vc_show_inline_edit_form', 'buildInlineEditForm');
         $this->addAction('admin_init', 'jsComposerEditPage', 5);
         $this->composer->inlineEditor()->addFilter('page_row_actions', 'renderRowAction');
         $this->composer->inlineEditor()->addFilter('post_row_actions', 'renderRowAction');
     }
     vc_automapper()->addAction('wp_ajax_vc_automapper', 'goAction');
     if (vc_is_inline()) {
         $this->composer->inlineEditor()->addFilter('vc_single_param_edit', 'changeEditFormFieldParams');
         $this->composer->inlineEditor()->addFilter('vc_edit_form_class', 'changeEditFormParams');
     }
     $this->composer->addAction('admin_init', 'renderInlineEditor');
     // 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');
 }
Beispiel #6
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');
 }
Beispiel #7
0
/**
 * Build and enqueue js/css for automapper settings tab.
 * @since 4.5
 */
function vc_automapper_init()
{
    vc_automapper()->build();
}
Beispiel #8
0
<form action="options.php" method="post" id="vc_settings-automapper"
      class="vc_settings-tab-content vc_settings-tab-content-active"<?php 
echo apply_filters('vc_setting-tab-form-automapper', '');
?>
>
	<?php 
vc_automapper()->renderHtml();
?>
</form>
Beispiel #9
0
/**
 * Build and enqueue js/css for automapper settings tab.
 * @since 4.5
 */
function vc_automapper_init()
{
    vc_user_access()->wpAny('manage_options')->part('settings')->can('vc-automapper-tab')->get() && vc_automapper()->build();
}
Beispiel #10
0
 function vc_atm_map()
 {
     vc_automapper()->map();
 }
Beispiel #11
0
/**
 * 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();
    }
}
/**
 * Build and enqueue js/css for automapper settings tab.
 * @since 4.5
 */
function vc_automapper_init()
{
    current_user_can('manage_options') && vc_automapper()->build();
}
Beispiel #13
0
         }
     }
     /* Remove admin menus */
     if (!$nm_vcomp_stock) {
         function nm_vc_remove_admin_menus()
         {
             remove_submenu_page('vc-general', 'vc-automapper');
             remove_submenu_page('vc-general', 'edit.php?post_type=vc_grid_item');
             //remove_submenu_page( 'vc-general', 'vc-welcome' ); // Note: Don't disable, this page is displayed after plugin activation (blank page with permission message displaying otherwise)
         }
         add_action('admin_menu', 'nm_vc_remove_admin_menus', 1000);
     }
     // Disable shortcode automapper feature
     if (!$nm_vcomp_stock) {
         if (function_exists('vc_automapper')) {
             vc_automapper()->setDisabled(true);
         }
     }
     /* Remove "vc_teaser" metabox */
     function nm_vc_remove_teaser_metabox()
     {
         remove_meta_box('vc_teaser', '', 'side');
     }
     add_action('admin_head', 'nm_vc_remove_teaser_metabox');
     // Set default editor post types (will not be used if the "content_types" VC setting is already saved - see fix below)
     $post_types = array('page');
     vc_set_default_editor_post_types($post_types);
     // Default editor post types: Un-comment and refresh WP admin to save/reset the "content_types" VC option
     // NOTE: Remember to comment-out after page refresh!
     //vc_settings()->set( 'content_types', $post_types );
 }