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'));
 }
Example #2
0
 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;
 }
Example #3
0
 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');
 }
Example #4
0
 /**
  * Creates vc_row shortcode string.
  * @deprecated
  */
 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;
 }
Example #5
0
 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;
 }
Example #6
0
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;
 }
Example #9
0
 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());
 }
Example #10
0
 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();
 }
Example #11
0
        <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 
Example #12
0
 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;
 }
Example #13
0
 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;
 }