khaihihi
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?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.
|
||||
*
|
||||
* @return string
|
||||
* @since 4.5
|
||||
*/
|
||||
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() && ( strpos( vc_request_param( 'action' ), 'vc_automapper' ) !== false || 'vc-automapper' === vc_get_param( 'page' ) ) && add_action( 'admin_init', 'vc_automapper_init' );
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
function vc_page_settings_custom_css_load() {
|
||||
wp_enqueue_script( 'ace-editor', vc_asset_url( 'lib/bower/ace-builds/src-min-noconflict/ace.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
|
||||
}
|
||||
|
||||
add_action( 'vc-settings-render-tab-vc-custom_css', 'vc_page_settings_custom_css_load' );
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check for current less version during page open
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
add_action( 'vc_before_init', 'vc_check_for_custom_css_build' );
|
||||
|
||||
/**
|
||||
* Function check is system has custom build of css
|
||||
* and check it version in comparison with current VC version
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
function vc_check_for_custom_css_build() {
|
||||
$version = vc_settings()->getCustomCssVersion();
|
||||
if ( vc_user_access()->wpAny( 'manage_options' )->part( 'settings' )->can( 'vc-color-tab' )
|
||||
->get() && vc_settings()->useCustomCss() && ( ! $version || version_compare( WPB_VC_VERSION, $version, '<>' ) ) ) {
|
||||
add_action( 'admin_notices', 'vc_custom_css_admin_notice' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display admin notice depending on current page
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
function vc_custom_css_admin_notice() {
|
||||
global $current_screen;
|
||||
vc_settings()->set( 'compiled_js_composer_less', '' );
|
||||
$class = 'notice notice-warning vc_settings-custom-design-notice';
|
||||
$message_important = esc_html__( 'Important notice', 'js_composer' );
|
||||
if ( is_object( $current_screen ) && isset( $current_screen->id ) && 'visual-composer_page_vc-color' === $current_screen->id ) {
|
||||
$message = esc_html__( 'You have an outdated version of WPBakery Page Builder Design Options. It is required to review and save it.', 'js_composer' );
|
||||
echo '<div class="' . esc_attr( $class ) . '"><p><strong>' . esc_html( $message_important ) . '</strong>: ' . esc_html( $message ) . '</p></div>';
|
||||
} else {
|
||||
$message = esc_html__( 'You have an outdated version of WPBakery Page Builder Design Options. It is required to review and save it.', 'js_composer' );
|
||||
$btnClass = 'button button-primary button-large vc_button-settings-less';
|
||||
echo '<div class="' . esc_attr( $class ) . '"><p><strong>' . esc_html( $message_important ) . '</strong>: ' . esc_html( $message ) . '</p>' . '<p>';
|
||||
echo '<a ' . implode( ' ', array(
|
||||
'href="' . esc_url( admin_url( 'admin.php?page=vc-color' ) ) . '"',
|
||||
'class="' . esc_attr( $btnClass ) . '"',
|
||||
'id="vc_less-save-button"',
|
||||
'style="vertical-align: baseline;"',
|
||||
// needed to fix ":active bug"
|
||||
) ) . '>';
|
||||
echo esc_html__( 'Open Design Options', 'js_composer' ) . '</a>';
|
||||
echo '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $submitButtonAttributes
|
||||
* @return mixed
|
||||
*/
|
||||
function vc_page_settings_tab_color_submit_attributes( $submitButtonAttributes ) {
|
||||
$submitButtonAttributes['data-vc-less-path'] = vc_str_remove_protocol( vc_asset_url( 'less/js_composer.less' ) );
|
||||
$submitButtonAttributes['data-vc-less-root'] = vc_str_remove_protocol( vc_asset_url( 'less' ) );
|
||||
$submitButtonAttributes['data-vc-less-variables'] = wp_json_encode( apply_filters( 'vc_settings-less-variables', array(
|
||||
// Main accent color:
|
||||
'vc_grey' => array(
|
||||
'key' => 'wpb_js_vc_color',
|
||||
'default' => vc_settings()->getDefault( 'vc_color' ),
|
||||
),
|
||||
// Hover color
|
||||
'vc_grey_hover' => array(
|
||||
'key' => 'wpb_js_vc_color_hover',
|
||||
'default' => vc_settings()->getDefault( 'vc_color_hover' ),
|
||||
),
|
||||
'vc_image_slider_link_active' => 'wpb_js_vc_color_hover',
|
||||
// Call to action background color
|
||||
'vc_call_to_action_bg' => 'wpb_js_vc_color_call_to_action_bg',
|
||||
'vc_call_to_action_2_bg' => 'wpb_js_vc_color_call_to_action_bg',
|
||||
'vc_call_to_action_border' => array(
|
||||
'key' => 'wpb_js_vc_color_call_to_action_border',
|
||||
// darken 5%
|
||||
'default_key' => 'wpb_js_vc_color',
|
||||
'modify_output' => array(
|
||||
array(
|
||||
'plain' => array(
|
||||
'darken({{ value }}, 5%)',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Google maps background color
|
||||
'vc_google_maps_bg' => 'wpb_js_vc_color_google_maps_bg',
|
||||
// Post slider caption background color
|
||||
'vc_post_slider_caption_bg' => 'wpb_js_vc_color_post_slider_caption_bg',
|
||||
// Progress bar background color
|
||||
'vc_progress_bar_bg' => 'wpb_js_vc_color_progress_bar_bg',
|
||||
// Separator border color
|
||||
'vc_separator_border' => 'wpb_js_vc_color_separator_border',
|
||||
// Tabs navigation background color
|
||||
'vc_tab_bg' => 'wpb_js_vc_color_tab_bg',
|
||||
// Active tab background color
|
||||
'vc_tab_bg_active' => 'wpb_js_vc_color_tab_bg_active',
|
||||
// Elements bottom margin
|
||||
'vc_element_margin_bottom' => array(
|
||||
'key' => 'wpb_js_margin',
|
||||
'default' => vc_settings()->getDefault( 'margin' ),
|
||||
),
|
||||
// Grid gutter width
|
||||
'grid-gutter-width' => array(
|
||||
'key' => 'wpb_js_gutter',
|
||||
'default' => vc_settings()->getDefault( 'gutter' ),
|
||||
'modify_output' => array(
|
||||
array(
|
||||
'plain' => array(
|
||||
'{{ value }}px',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'screen-sm-min' => array(
|
||||
'key' => 'wpb_js_responsive_max',
|
||||
'default' => vc_settings()->getDefault( 'responsive_max' ),
|
||||
'modify_output' => array(
|
||||
array(
|
||||
'plain' => array(
|
||||
'{{ value }}px',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
) ) );
|
||||
|
||||
return $submitButtonAttributes;
|
||||
}
|
||||
|
||||
function vc_page_settings_desing_options_load() {
|
||||
add_filter( 'vc_settings-tab-submit-button-attributes-color', 'vc_page_settings_tab_color_submit_attributes' );
|
||||
wp_enqueue_script( 'vc_less_js', vc_asset_url( 'lib/bower/lessjs/dist/less.min.js' ), array(), WPB_VC_VERSION, true );
|
||||
}
|
||||
|
||||
add_action( 'vc-settings-render-tab-vc-color', 'vc_page_settings_desing_options_load' );
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
/**
|
||||
* @param $tabs
|
||||
* @return array
|
||||
*/
|
||||
function vc_settings_tabs_vc_roles( $tabs ) {
|
||||
// inster after vc-general tab
|
||||
if ( array_key_exists( 'vc-general', $tabs ) ) {
|
||||
$new = array();
|
||||
foreach ( $tabs as $key => $value ) {
|
||||
$new[ $key ] = $value;
|
||||
if ( 'vc-general' === $key ) {
|
||||
$new['vc-roles'] = esc_html__( 'Role Manager', 'js_composer' );
|
||||
}
|
||||
}
|
||||
$tabs = $new;
|
||||
} else {
|
||||
$tabs['vc-roles'] = esc_html__( 'Roles Manager', 'js_composer' );
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
if ( ! is_network_admin() ) {
|
||||
add_filter( 'vc_settings_tabs', 'vc_settings_tabs_vc_roles' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
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 wp_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_accordion_script', vc_asset_url( 'lib/vc_accordion/vc-accordion.min.js' ), array( 'jquery' ), WPB_VC_VERSION, true );
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'vc_settings_render_tab_vc_roles_scripts' );
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.5
|
||||
*/
|
||||
function vc_page_css_enqueue() {
|
||||
wp_enqueue_style( 'vc_page-css', vc_asset_url( 'css/js_composer_settings.min.css' ), array(), WPB_VC_VERSION );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build group page objects.
|
||||
*
|
||||
* @param $slug
|
||||
* @param $title
|
||||
* @param $tab
|
||||
*
|
||||
* @return Vc_Pages_Group
|
||||
* @since 4.5
|
||||
*
|
||||
*/
|
||||
function vc_pages_group_build( $slug, $title, $tab = '' ) {
|
||||
$vc_page_welcome_tabs = vc_get_page_welcome_tabs();
|
||||
require_once vc_path_dir( 'CORE_DIR', 'class-vc-page.php' );
|
||||
require_once vc_path_dir( 'CORE_DIR', 'class-vc-pages-group.php' );
|
||||
// Create page.
|
||||
if ( ! strlen( $tab ) ) {
|
||||
$tab = $slug;
|
||||
}
|
||||
$page = new Vc_Page();
|
||||
$page->setSlug( $tab )->setTitle( $title )->setTemplatePath( 'pages/' . $slug . '/' . $tab . '.php' );
|
||||
// Create page group to stick with other in template.
|
||||
$pages_group = new Vc_Pages_Group();
|
||||
$pages_group->setSlug( $slug )->setPages( $vc_page_welcome_tabs )->setActivePage( $page )->setTemplatePath( 'pages/vc-welcome/index.php' );
|
||||
|
||||
return $pages_group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.5
|
||||
*/
|
||||
function vc_menu_page_build() {
|
||||
if ( vc_user_access()->wpAny( 'manage_options' )->part( 'settings' )->can( 'vc-general-tab' )->get() ) {
|
||||
define( 'VC_PAGE_MAIN_SLUG', 'vc-general' );
|
||||
} else {
|
||||
define( 'VC_PAGE_MAIN_SLUG', 'vc-welcome' );
|
||||
}
|
||||
add_menu_page( esc_html__( 'WPBakery Page Builder', 'js_composer' ), esc_html__( 'WPBakery Page Builder', 'js_composer' ), 'edit_posts', VC_PAGE_MAIN_SLUG, null, vc_asset_url( 'vc/logo/wpb-logo-white_32.svg' ), 76 );
|
||||
do_action( 'vc_menu_page_build' );
|
||||
}
|
||||
|
||||
function vc_network_menu_page_build() {
|
||||
if ( ! vc_is_network_plugin() ) {
|
||||
return;
|
||||
}
|
||||
if ( vc_user_access()->wpAny( 'manage_options' )->part( 'settings' )->can( 'vc-general-tab' )->get() && ! is_main_site() ) {
|
||||
define( 'VC_PAGE_MAIN_SLUG', 'vc-general' );
|
||||
} else {
|
||||
define( 'VC_PAGE_MAIN_SLUG', 'vc-welcome' );
|
||||
}
|
||||
add_menu_page( esc_html__( 'WPBakery Page Builder', 'js_composer' ), esc_html__( 'WPBakery Page Builder', 'js_composer' ), 'exist', VC_PAGE_MAIN_SLUG, null, vc_asset_url( 'vc/logo/wpb-logo-white_32.svg' ), 76 );
|
||||
do_action( 'vc_network_menu_page_build' );
|
||||
}
|
||||
|
||||
add_action( 'admin_menu', 'vc_menu_page_build' );
|
||||
add_action( 'network_admin_menu', 'vc_network_menu_page_build' );
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
function vc_page_settings_render() {
|
||||
$page = vc_get_param( 'page' );
|
||||
do_action( 'vc_page_settings_render-' . $page );
|
||||
vc_settings()->renderTab( $page );
|
||||
}
|
||||
|
||||
function vc_page_settings_build() {
|
||||
if ( ! vc_user_access()->wpAny( 'manage_options' )->get() ) {
|
||||
return;
|
||||
}
|
||||
$tabs = vc_settings()->getTabs();
|
||||
foreach ( $tabs as $slug => $title ) {
|
||||
$has_access = vc_user_access()->part( 'settings' )->can( $slug . '-tab' )->get();
|
||||
|
||||
if ( $has_access ) {
|
||||
$page = add_submenu_page( VC_PAGE_MAIN_SLUG, $title, $title, 'manage_options', $slug, 'vc_page_settings_render' );
|
||||
add_action( 'load-' . $page, array(
|
||||
vc_settings(),
|
||||
'adminLoad',
|
||||
) );
|
||||
}
|
||||
}
|
||||
do_action( 'vc_page_settings_build' );
|
||||
}
|
||||
|
||||
function vc_page_settings_admin_init() {
|
||||
vc_settings()->initAdmin();
|
||||
}
|
||||
|
||||
add_action( 'vc_menu_page_build', 'vc_page_settings_build' );
|
||||
add_action( 'vc_network_menu_page_build', 'vc_page_settings_build' );
|
||||
add_action( 'admin_init', 'vc_page_settings_admin_init' );
|
||||
add_action( 'vc-settings-render-tab-vc-roles', 'vc_settings_enqueue_js' );
|
||||
|
||||
function vc_settings_enqueue_js() {
|
||||
// enqueue accordion in vc-roles page only
|
||||
wp_enqueue_script( 'vc_accordion_script' );
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get welcome pages main slug.
|
||||
*
|
||||
* @return mixed|string
|
||||
* @since 4.5
|
||||
*/
|
||||
function vc_page_welcome_slug() {
|
||||
$vc_page_welcome_tabs = vc_get_page_welcome_tabs();
|
||||
|
||||
return isset( $vc_page_welcome_tabs ) ? key( $vc_page_welcome_tabs ) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build vc-welcome page block which will be shown after Vc installation.
|
||||
*
|
||||
* vc_filter: vc_page_welcome_render_capabilities
|
||||
*
|
||||
* @since 4.5
|
||||
*/
|
||||
function vc_page_welcome_render() {
|
||||
$vc_page_welcome_tabs = vc_get_page_welcome_tabs();
|
||||
$slug = vc_page_welcome_slug();
|
||||
$tab_slug = vc_get_param( 'tab', $slug );
|
||||
// If tab slug in the list please render;
|
||||
if ( ! empty( $tab_slug ) && isset( $vc_page_welcome_tabs[ $tab_slug ] ) ) {
|
||||
$pages_group = vc_pages_group_build( $slug, $vc_page_welcome_tabs[ $tab_slug ], $tab_slug );
|
||||
$pages_group->render();
|
||||
}
|
||||
}
|
||||
|
||||
function vc_page_welcome_add_sub_page() {
|
||||
// Add submenu page
|
||||
$page = add_submenu_page( VC_PAGE_MAIN_SLUG, esc_html__( 'About', 'js_composer' ), esc_html__( 'About', 'js_composer' ), 'edit_posts', vc_page_welcome_slug(), 'vc_page_welcome_render' );
|
||||
// Css for perfect styling.
|
||||
add_action( 'admin_print_styles-' . $page, 'vc_page_css_enqueue' );
|
||||
|
||||
}
|
||||
|
||||
function vc_welcome_menu_hooks() {
|
||||
$settings_tab_enabled = vc_user_access()->wpAny( 'manage_options' )->part( 'settings' )->can( 'vc-general-tab' )->get();
|
||||
add_action( 'vc_menu_page_build', 'vc_page_welcome_add_sub_page', $settings_tab_enabled ? 11 : 1 );
|
||||
}
|
||||
|
||||
function vc_welcome_menu_hooks_network() {
|
||||
if ( ! vc_is_network_plugin() ) {
|
||||
return;
|
||||
}
|
||||
$settings_tab_enabled = vc_user_access()->wpAny( 'manage_options' )->part( 'settings' )->can( 'vc-general-tab' )->get();
|
||||
add_action( 'vc_network_menu_page_build', 'vc_page_welcome_add_sub_page', $settings_tab_enabled && ! is_main_site() ? 11 : 1 );
|
||||
}
|
||||
|
||||
add_action( 'admin_menu', 'vc_welcome_menu_hooks', 9 );
|
||||
add_action( 'network_admin_menu', 'vc_welcome_menu_hooks_network', 9 );
|
||||
/**
|
||||
* ====================
|
||||
* Redirect to welcome page on plugin activation.
|
||||
* ====================
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do redirect if required on welcome page
|
||||
* @since 4.5
|
||||
*/
|
||||
function vc_page_welcome_redirect() {
|
||||
$redirect = get_transient( '_vc_page_welcome_redirect' );
|
||||
delete_transient( '_vc_page_welcome_redirect' );
|
||||
if ( $redirect ) {
|
||||
wp_safe_redirect( admin_url( 'admin.php?page=' . rawurlencode( vc_page_welcome_slug() ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Enables redirect on activation.
|
||||
add_action( 'vc_activation_hook', 'vc_page_welcome_set_redirect' );
|
||||
add_action( 'admin_init', 'vc_page_welcome_redirect' );
|
||||
|
||||
/**
|
||||
* @return mixed|void
|
||||
*/
|
||||
function vc_get_page_welcome_tabs() {
|
||||
global $vc_page_welcome_tabs;
|
||||
$vc_page_welcome_tabs = apply_filters( 'vc_page-welcome-slugs-list', array(
|
||||
'vc-welcome' => esc_html__( 'What\'s New', 'js_composer' ),
|
||||
'vc-faq' => esc_html__( 'FAQ', 'js_composer' ),
|
||||
'vc-resources' => esc_html__( 'Resources', 'js_composer' ),
|
||||
) );
|
||||
|
||||
return $vc_page_welcome_tabs;
|
||||
}
|
||||
Reference in New Issue
Block a user