first commit

This commit is contained in:
Ryan Ariana
2024-05-06 11:04:37 +07:00
commit aee061ddba
7322 changed files with 2918816 additions and 0 deletions

View File

@@ -0,0 +1,159 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Show in WP Dashboard notice about the plugin is not activated.
*
* @return void
*/
function hello_elementor_fail_load_admin_notice() {
// Leave to Elementor Pro to manage this.
if ( function_exists( 'elementor_pro_load_plugin' ) ) {
return;
}
$screen = get_current_screen();
if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
return;
}
if ( 'true' === get_user_meta( get_current_user_id(), '_hello_elementor_install_notice', true ) ) {
return;
}
$plugin = 'elementor/elementor.php';
$installed_plugins = get_plugins();
$is_elementor_installed = isset( $installed_plugins[ $plugin ] );
$message = esc_html__( 'The Hello Theme is a lightweight starter theme that works perfectly with the Elementor award-winning site builder plugin.', 'hello-elementor' );
if ( $is_elementor_installed ) {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
$message .= ' ' . esc_html__( 'Once you activate the plugin, you are only one click away from building an amazing website.', 'hello-elementor' );
$button_text = esc_html__( 'Activate Elementor', 'hello-elementor' );
$button_link = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
} else {
if ( ! current_user_can( 'install_plugins' ) ) {
return;
}
$message .= ' ' . esc_html__( 'Once you download and activate the plugin, you are only one click away from building an amazing website.', 'hello-elementor' );
$button_text = esc_html__( 'Install Elementor', 'hello-elementor' );
$button_link = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
}
?>
<style>
.notice.hello-elementor-notice {
border: 1px solid #ccd0d4;
border-inline-start: 4px solid #9b0a46 !important;
box-shadow: 0 1px 4px rgba(0,0,0,0.15);
display: flex;
padding: 0;
}
.notice.hello-elementor-notice.hello-elementor-install-elementor {
padding: 0;
}
.notice.hello-elementor-notice .hello-elementor-notice-aside {
display: flex;
align-items: start;
justify-content: center;
padding: 20px 10px;
background: rgba(215,43,63,0.04);
}
.notice.hello-elementor-notice .hello-elementor-notice-aside img {
width: 1.5rem;
}
.notice.hello-elementor-notice .hello-elementor-notice-content {
display: flex;
flex-direction: column;
gap: 5px;
padding: 20px;
width: 100%;
}
.notice.hello-elementor-notice .hello-elementor-notice-content h3,
.notice.hello-elementor-notice .hello-elementor-notice-content p {
padding: 0;
margin: 0;
}
.notice.hello-elementor-notice .hello-elementor-information-link {
align-self: start;
}
.notice.hello-elementor-notice .hello-elementor-install-button {
align-self: start;
background-color: #127DB8;
border-radius: 3px;
color: #fff;
text-decoration: none;
height: auto;
line-height: 20px;
padding: 0.4375rem 0.75rem;
margin-block-start: 15px;
}
.notice.hello-elementor-notice .hello-elementor-install-button:active {
transform: translateY(1px);
}
@media (max-width: 767px) {
.notice.hello-elementor-notice .hello-elementor-notice-aside {
padding: 10px;
}
.notice.hello-elementor-notice .hello-elementor-notice-content {
gap: 10px;
padding: 10px;
}
}
</style>
<script>
window.addEventListener( 'load', () => {
const dismissNotice = document.querySelector( '.notice.hello-elementor-install-elementor button.notice-dismiss' );
dismissNotice.addEventListener( 'click', async ( event ) => {
event.preventDefault();
var formData = new FormData();
formData.append( 'action', 'hello_elementor_set_admin_notice_viewed' );
formData.append( 'dismiss_nonce', '<?php echo esc_js( wp_create_nonce( 'hello_elementor_dismiss_install_notice' ) ); ?>' );
await fetch( ajaxurl, { method: 'POST', body: formData } );
} );
} );
</script>
<div class="notice updated is-dismissible hello-elementor-notice hello-elementor-install-elementor">
<div class="hello-elementor-notice-aside">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/elementor-notice-icon.svg' ); ?>" alt="<?php echo esc_attr__( 'Get Elementor', 'hello-elementor' ); ?>" />
</div>
<div class="hello-elementor-notice-content">
<h3><?php echo esc_html__( 'Thanks for installing the Hello Theme!', 'hello-elementor' ); ?></h3>
<p><?php echo esc_html( $message ); ?></p>
<a class="hello-elementor-information-link" href="https://go.elementor.com/hello-theme-learn/" target="_blank"><?php echo esc_html__( 'Explore Elementor Site Builder Plugin', 'hello-elementor' ); ?></a>
<a class="hello-elementor-install-button" href="<?php echo esc_attr( $button_link ); ?>"><?php echo esc_html( $button_text ); ?></a>
</div>
</div>
<?php
}
/**
* Set dismissed admin notice as viewed.
*
* @return void
*/
function ajax_hello_elementor_set_admin_notice_viewed() {
check_ajax_referer( 'hello_elementor_dismiss_install_notice', 'dismiss_nonce' );
update_user_meta( get_current_user_id(), '_hello_elementor_install_notice', 'true' );
die;
}
add_action( 'wp_ajax_hello_elementor_set_admin_notice_viewed', 'ajax_hello_elementor_set_admin_notice_viewed' );
if ( ! did_action( 'elementor/loaded' ) ) {
add_action( 'admin_notices', 'hello_elementor_fail_load_admin_notice' );
}

View File

@@ -0,0 +1,60 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Register Customizer controls.
*
* @return void
*/
function hello_customizer_register( $wp_customize ) {
require get_template_directory() . '/includes/customizer/customizer-action-links.php';
$wp_customize->add_section(
'hello-options',
[
'title' => esc_html__( 'Header & Footer', 'hello-elementor' ),
'capability' => 'edit_theme_options',
]
);
$wp_customize->add_setting(
'hello-header-footer',
[
'sanitize_callback' => false,
'transport' => 'refresh',
]
);
$wp_customize->add_control(
new HelloElementor\Includes\Customizer\Hello_Customizer_Action_Links(
$wp_customize,
'hello-header-footer',
[
'section' => 'hello-options',
'priority' => 20,
]
)
);
}
add_action( 'customize_register', 'hello_customizer_register' );
/**
* Enqueue Customizer CSS.
*
* @return void
*/
function hello_customizer_styles() {
$min_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_style(
'hello-elementor-customizer',
get_template_directory_uri() . '/customizer' . $min_suffix . '.css',
[],
HELLO_ELEMENTOR_VERSION
);
}
add_action( 'admin_enqueue_scripts', 'hello_customizer_styles' );

View File

@@ -0,0 +1,145 @@
<?php
namespace HelloElementor\Includes\Customizer;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Hello_Customizer_Action_Links extends \WP_Customize_Control {
// Whitelist content parameter
public $content = '';
/**
* Render the control's content.
*
* Allows the content to be overridden without having to rewrite the wrapper.
*
* @return void
*/
public function render_content() {
$this->print_customizer_action_links();
if ( isset( $this->description ) ) {
echo '<span class="description customize-control-description">' . wp_kses_post( $this->description ) . '</span>';
}
}
/**
* Print customizer action links.
*
* @return void
*/
private function print_customizer_action_links() {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$action_link_data = [];
$action_link_type = '';
$installed_plugins = get_plugins();
if ( ! isset( $installed_plugins['elementor/elementor.php'] ) ) {
$action_link_type = 'install-elementor';
} elseif ( ! defined( 'ELEMENTOR_VERSION' ) ) {
$action_link_type = 'activate-elementor';
} elseif ( ! hello_header_footer_experiment_active() ) {
$action_link_type = 'activate-header-footer-experiment';
} else {
$action_link_type = 'style-header-footer';
}
switch ( $action_link_type ) {
case 'install-elementor':
$action_link_data = [
'image' => get_template_directory_uri() . '/assets/images/elementor.svg',
'alt' => esc_attr__( 'Elementor', 'hello-elementor' ),
'title' => esc_html__( 'Install Elementor', 'hello-elementor' ),
'message' => esc_html__( 'Create cross-site header & footer using Elementor.', 'hello-elementor' ),
'button' => esc_html__( 'Install Elementor', 'hello-elementor' ),
'link' => wp_nonce_url(
add_query_arg(
[
'action' => 'install-plugin',
'plugin' => 'elementor',
],
admin_url( 'update.php' )
),
'install-plugin_elementor'
),
];
break;
case 'activate-elementor':
$action_link_data = [
'image' => get_template_directory_uri() . '/assets/images/elementor.svg',
'alt' => esc_attr__( 'Elementor', 'hello-elementor' ),
'title' => esc_html__( 'Activate Elementor', 'hello-elementor' ),
'message' => esc_html__( 'Create cross-site header & footer using Elementor.', 'hello-elementor' ),
'button' => esc_html__( 'Activate Elementor', 'hello-elementor' ),
'link' => wp_nonce_url( 'plugins.php?action=activate&plugin=elementor/elementor.php', 'activate-plugin_elementor/elementor.php' ),
];
break;
case 'activate-header-footer-experiment':
$action_link_data = [
'image' => get_template_directory_uri() . '/assets/images/elementor.svg',
'alt' => esc_attr__( 'Elementor', 'hello-elementor' ),
'title' => esc_html__( 'Style using Elementor', 'hello-elementor' ),
'message' => esc_html__( 'Design your cross-site header & footer from Elementors "Site Settings" panel.', 'hello-elementor' ),
'button' => esc_html__( 'Activate header & footer experiment', 'hello-elementor' ),
'link' => wp_nonce_url( 'admin.php?page=elementor#tab-experiments' ),
];
break;
case 'style-header-footer':
$action_link_data = [
'image' => get_template_directory_uri() . '/assets/images/elementor.svg',
'alt' => esc_attr__( 'Elementor', 'hello-elementor' ),
'title' => esc_html__( 'Style cross-site header & footer', 'hello-elementor' ),
'message' => esc_html__( 'Customize your cross-site header & footer from Elementors "Site Settings" panel.', 'hello-elementor' ),
'button' => esc_html__( 'Start Designing', 'hello-elementor' ),
'link' => wp_nonce_url( 'post.php?post=' . get_option( 'elementor_active_kit' ) . '&action=elementor' ),
];
break;
}
$customizer_content = $this->get_customizer_action_links_html( $action_link_data );
echo wp_kses_post( $customizer_content );
}
/**
* Get the customizer action links HTML.
*
* @param array $data
*
* @return string
*/
private function get_customizer_action_links_html( $data ) {
if (
empty( $data )
|| ! isset( $data['image'] )
|| ! isset( $data['alt'] )
|| ! isset( $data['title'] )
|| ! isset( $data['message'] )
|| ! isset( $data['link'] )
|| ! isset( $data['button'] )
) {
return;
}
return sprintf(
'<div class="hello-action-links">
<img src="%1$s" alt="%2$s">
<p class="hello-action-links-title">%3$s</p>
<p class="hello-action-links-message">%4$s</p>
<a class="button button-primary" target="_blank" href="%5$s">%6$s</a>
</div>',
$data['image'],
$data['alt'],
$data['title'],
$data['message'],
$data['link'],
$data['button'],
);
}
}

View File

@@ -0,0 +1,248 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Register Site Settings Controls.
*/
add_action( 'elementor/init', 'hello_elementor_settings_init' );
function hello_elementor_settings_init() {
if ( ! hello_header_footer_experiment_active() ) {
return;
}
require 'settings/settings-header.php';
require 'settings/settings-footer.php';
add_action( 'elementor/kit/register_tabs', function( \Elementor\Core\Kits\Documents\Kit $kit ) {
if ( ! hello_elementor_display_header_footer() ) {
return;
}
$kit->register_tab( 'hello-settings-header', HelloElementor\Includes\Settings\Settings_Header::class );
$kit->register_tab( 'hello-settings-footer', HelloElementor\Includes\Settings\Settings_Footer::class );
}, 1, 40 );
}
/**
* Helper function to return a setting.
*
* Saves 2 lines to get kit, then get setting. Also caches the kit and setting.
*
* @param string $setting_id
* @return string|array same as the Elementor internal function does.
*/
function hello_elementor_get_setting( $setting_id ) {
global $hello_elementor_settings;
$return = '';
if ( ! isset( $hello_elementor_settings['kit_settings'] ) ) {
$kit = \Elementor\Plugin::$instance->kits_manager->get_active_kit();
$hello_elementor_settings['kit_settings'] = $kit->get_settings();
}
if ( isset( $hello_elementor_settings['kit_settings'][ $setting_id ] ) ) {
$return = $hello_elementor_settings['kit_settings'][ $setting_id ];
}
return apply_filters( 'hello_elementor_' . $setting_id, $return );
}
/**
* Helper function to show/hide elements
*
* This works with switches, if the setting ID that has been passed is toggled on, we'll return show, otherwise we'll return hide
*
* @param string $setting_id
* @return string|array same as the Elementor internal function does.
*/
function hello_show_or_hide( $setting_id ) {
return ( 'yes' === hello_elementor_get_setting( $setting_id ) ? 'show' : 'hide' );
}
/**
* Helper function to translate the header layout setting into a class name.
*
* @return string
*/
function hello_get_header_layout_class() {
$layout_classes = [];
$header_layout = hello_elementor_get_setting( 'hello_header_layout' );
if ( 'inverted' === $header_layout ) {
$layout_classes[] = 'header-inverted';
} elseif ( 'stacked' === $header_layout ) {
$layout_classes[] = 'header-stacked';
}
$header_width = hello_elementor_get_setting( 'hello_header_width' );
if ( 'full-width' === $header_width ) {
$layout_classes[] = 'header-full-width';
}
$header_menu_dropdown = hello_elementor_get_setting( 'hello_header_menu_dropdown' );
if ( 'tablet' === $header_menu_dropdown ) {
$layout_classes[] = 'menu-dropdown-tablet';
} elseif ( 'mobile' === $header_menu_dropdown ) {
$layout_classes[] = 'menu-dropdown-mobile';
} elseif ( 'none' === $header_menu_dropdown ) {
$layout_classes[] = 'menu-dropdown-none';
}
$hello_header_menu_layout = hello_elementor_get_setting( 'hello_header_menu_layout' );
if ( 'dropdown' === $hello_header_menu_layout ) {
$layout_classes[] = 'menu-layout-dropdown';
}
return implode( ' ', $layout_classes );
}
/**
* Helper function to translate the footer layout setting into a class name.
*
* @return string
*/
function hello_get_footer_layout_class() {
$footer_layout = hello_elementor_get_setting( 'hello_footer_layout' );
$layout_classes = [];
if ( 'inverted' === $footer_layout ) {
$layout_classes[] = 'footer-inverted';
} elseif ( 'stacked' === $footer_layout ) {
$layout_classes[] = 'footer-stacked';
}
$footer_width = hello_elementor_get_setting( 'hello_footer_width' );
if ( 'full-width' === $footer_width ) {
$layout_classes[] = 'footer-full-width';
}
if ( hello_elementor_get_setting( 'hello_footer_copyright_display' ) && '' !== hello_elementor_get_setting( 'hello_footer_copyright_text' ) ) {
$layout_classes[] = 'footer-has-copyright';
}
return implode( ' ', $layout_classes );
}
add_action( 'elementor/editor/after_enqueue_scripts', function() {
if ( ! hello_header_footer_experiment_active() ) {
return;
}
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script(
'hello-theme-editor',
get_template_directory_uri() . '/assets/js/hello-editor' . $suffix . '.js',
[ 'jquery', 'elementor-editor' ],
HELLO_ELEMENTOR_VERSION,
true
);
wp_enqueue_style(
'hello-editor',
get_template_directory_uri() . '/editor' . $suffix . '.css',
[],
HELLO_ELEMENTOR_VERSION
);
} );
add_action( 'wp_enqueue_scripts', function() {
if ( ! hello_elementor_display_header_footer() ) {
return;
}
if ( ! hello_header_footer_experiment_active() ) {
return;
}
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script(
'hello-theme-frontend',
get_template_directory_uri() . '/assets/js/hello-frontend' . $suffix . '.js',
[],
HELLO_ELEMENTOR_VERSION,
true
);
\Elementor\Plugin::$instance->kits_manager->frontend_before_enqueue_styles();
} );
/**
* Helper function to decide whether to output the header template.
*
* @return bool
*/
function hello_get_header_display() {
$is_editor = isset( $_GET['elementor-preview'] );
return (
$is_editor
|| hello_elementor_get_setting( 'hello_header_logo_display' )
|| hello_elementor_get_setting( 'hello_header_tagline_display' )
|| hello_elementor_get_setting( 'hello_header_menu_display' )
);
}
/**
* Helper function to decide whether to output the footer template.
*
* @return bool
*/
function hello_get_footer_display() {
$is_editor = isset( $_GET['elementor-preview'] );
return (
$is_editor
|| hello_elementor_get_setting( 'hello_footer_logo_display' )
|| hello_elementor_get_setting( 'hello_footer_tagline_display' )
|| hello_elementor_get_setting( 'hello_footer_menu_display' )
|| hello_elementor_get_setting( 'hello_footer_copyright_display' )
);
}
/**
* Add Hello Elementor theme Header & Footer to Experiments.
*/
add_action( 'elementor/experiments/default-features-registered', function( \Elementor\Core\Experiments\Manager $experiments_manager ) {
$experiments_manager->add_feature( [
'name' => 'hello-theme-header-footer',
'title' => esc_html__( 'Hello Theme Header & Footer', 'hello-elementor' ),
'description' => sprintf(
'%1$s <a href="%2$s" target="_blank">%3$s</a>',
esc_html__( 'Customize and style the builtin Hello Themes cross-site header & footer from the Elementor "Site Settings" panel.', 'hello-elementor' ),
'https://go.elementor.com/wp-dash-header-footer',
esc_html__( 'Learn More', 'hello-elementor' )
),
'release_status' => $experiments_manager::RELEASE_STATUS_STABLE,
'new_site' => [
'minimum_installation_version' => '3.3.0',
'default_active' => $experiments_manager::STATE_ACTIVE,
],
] );
} );
/**
* Helper function to check if Header & Footer Experiment is Active/Inactive
*/
function hello_header_footer_experiment_active() {
// If Elementor is not active, return false
if ( ! did_action( 'elementor/loaded' ) ) {
return false;
}
// Backwards compat.
if ( ! method_exists( \Elementor\Plugin::$instance->experiments, 'is_feature_active' ) ) {
return false;
}
return (bool) ( \Elementor\Plugin::$instance->experiments->is_feature_active( 'hello-theme-header-footer' ) );
}

View File

@@ -0,0 +1,190 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
add_action( 'admin_menu', 'hello_elementor_settings_page' );
add_action( 'init', 'hello_elementor_tweak_settings', 0 );
/**
* Register theme settings page.
*/
function hello_elementor_settings_page() {
$menu_hook = '';
$menu_hook = add_theme_page(
esc_html__( 'Hello Theme Settings', 'hello-elementor' ),
esc_html__( 'Theme Settings', 'hello-elementor' ),
'manage_options',
'hello-theme-settings',
'hello_elementor_settings_page_render'
);
add_action( 'load-' . $menu_hook, function() {
add_action( 'admin_enqueue_scripts', 'hello_elementor_settings_page_scripts', 10 );
} );
}
/**
* Register settings page scripts.
*/
function hello_elementor_settings_page_scripts() {
$dir = get_template_directory() . '/assets/js';
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$handle = 'hello-admin';
$asset_path = "$dir/hello-admin.asset.php";
$asset_url = get_template_directory_uri() . '/assets/js';
if ( ! file_exists( $asset_path ) ) {
throw new \Error( 'You need to run `npm run build` for the "hello-theme" first.' );
}
$script_asset = require( $asset_path );
wp_enqueue_script(
$handle,
"$asset_url/$handle$suffix.js",
$script_asset['dependencies'],
$script_asset['version']
);
wp_set_script_translations( $handle, 'hello-elementor' );
wp_enqueue_style(
$handle,
"$asset_url/$handle$suffix.css",
[ 'wp-components' ],
$script_asset['version']
);
$plugins = get_plugins();
if ( ! isset( $plugins['elementor/elementor.php'] ) ) {
$action_link_type = 'install-elementor';
$action_link_url = wp_nonce_url(
add_query_arg(
[
'action' => 'install-plugin',
'plugin' => 'elementor',
],
admin_url( 'update.php' )
),
'install-plugin_elementor'
);
} elseif ( ! defined( 'ELEMENTOR_VERSION' ) ) {
$action_link_type = 'activate-elementor';
$action_link_url = wp_nonce_url( 'plugins.php?action=activate&plugin=elementor/elementor.php', 'activate-plugin_elementor/elementor.php' );
} elseif ( hello_header_footer_experiment_active() && ! hello_header_footer_experiment_active() ) {
$action_link_type = 'activate-header-footer-experiment';
$action_link_url = wp_nonce_url( 'admin.php?page=elementor#tab-experiments' );
} elseif ( hello_header_footer_experiment_active() ) {
$action_link_type = 'style-header-footer';
$action_link_url = wp_nonce_url( 'post.php?post=' . get_option( 'elementor_active_kit' ) . '&action=elementor' );
} else {
$action_link_type = '';
$action_link_url = '';
}
wp_localize_script(
$handle,
'helloAdminData',
[
'actionLinkType' => $action_link_type,
'actionLinkURL' => $action_link_url,
'templateDirectoryURI' => get_template_directory_uri(),
]
);
}
/**
* Render settings page wrapper element.
*/
function hello_elementor_settings_page_render() {
?>
<div id="hello-elementor-settings"></div>
<?php
}
/**
* Theme tweaks & settings.
*/
function hello_elementor_tweak_settings() {
$settings_group = 'hello_elementor_settings';
$settings = [
'DESCRIPTION_META_TAG' => '_description_meta_tag',
'SKIP_LINK' => '_skip_link',
'HEADER_FOOTER' => '_header_footer',
'PAGE_TITLE' => '_page_title',
'HELLO_STYLE' => '_hello_style',
'HELLO_THEME' => '_hello_theme',
];
hello_elementor_register_settings( $settings_group, $settings );
hello_elementor_render_tweaks( $settings_group, $settings );
}
/**
* Register theme settings.
*/
function hello_elementor_register_settings( $settings_group, $settings ) {
foreach ( $settings as $setting_key => $setting_value ) {
register_setting(
$settings_group,
$settings_group . $setting_value,
[
'default' => '',
'show_in_rest' => true,
'type' => 'string',
]
);
}
}
/**
* Run a tweek only if the user requested it.
*/
function hello_elementor_do_tweak( $setting, $tweak_callback ) {
$option = get_option( $setting );
if ( isset( $option ) && ( 'true' === $option ) && is_callable( $tweak_callback ) ) {
$tweak_callback();
}
}
/**
* Render theme tweaks.
*/
function hello_elementor_render_tweaks( $settings_group, $settings ) {
hello_elementor_do_tweak( $settings_group . $settings['DESCRIPTION_META_TAG'], function() {
remove_action( 'wp_head', 'hello_elementor_add_description_meta_tag' );
} );
hello_elementor_do_tweak( $settings_group . $settings['SKIP_LINK'], function() {
add_filter( 'hello_elementor_enable_skip_link', '__return_false' );
} );
hello_elementor_do_tweak( $settings_group . $settings['HEADER_FOOTER'], function() {
add_filter( 'hello_elementor_header_footer', '__return_false' );
} );
hello_elementor_do_tweak( $settings_group . $settings['PAGE_TITLE'], function() {
add_filter( 'hello_elementor_page_title', '__return_false' );
} );
hello_elementor_do_tweak( $settings_group . $settings['HELLO_STYLE'], function() {
add_filter( 'hello_elementor_enqueue_style', '__return_false' );
} );
hello_elementor_do_tweak( $settings_group . $settings['HELLO_THEME'], function() {
add_filter( 'hello_elementor_enqueue_theme_style', '__return_false' );
} );
}

View File

@@ -0,0 +1,532 @@
<?php
namespace HelloElementor\Includes\Settings;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Typography;
use Elementor\Core\Kits\Documents\Tabs\Tab_Base;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Settings_Footer extends Tab_Base {
public function get_id() {
return 'hello-settings-footer';
}
public function get_title() {
return esc_html__( 'Hello Theme Footer', 'hello-elementor' );
}
public function get_icon() {
return 'eicon-footer';
}
public function get_help_url() {
return '';
}
public function get_group() {
return 'theme-style';
}
protected function register_tab_controls() {
$this->start_controls_section(
'hello_footer_section',
[
'tab' => 'hello-settings-footer',
'label' => esc_html__( 'Footer', 'hello-elementor' ),
]
);
$this->add_control(
'hello_footer_logo_display',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Site Logo', 'hello-elementor' ),
'default' => 'yes',
'label_on' => esc_html__( 'Show', 'hello-elementor' ),
'label_off' => esc_html__( 'Hide', 'hello-elementor' ),
'selector' => '.site-footer .site-branding',
]
);
$this->add_control(
'hello_footer_tagline_display',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Tagline', 'hello-elementor' ),
'default' => 'yes',
'label_on' => esc_html__( 'Show', 'hello-elementor' ),
'label_off' => esc_html__( 'Hide', 'hello-elementor' ),
'selector' => '.site-footer .site-description',
]
);
$this->add_control(
'hello_footer_menu_display',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Menu', 'hello-elementor' ),
'default' => 'yes',
'label_on' => esc_html__( 'Show', 'hello-elementor' ),
'label_off' => esc_html__( 'Hide', 'hello-elementor' ),
'selector' => '.site-footer .site-navigation',
]
);
$this->add_control(
'hello_footer_copyright_display',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Copyright', 'hello-elementor' ),
'default' => 'yes',
'label_on' => esc_html__( 'Show', 'hello-elementor' ),
'label_off' => esc_html__( 'Hide', 'hello-elementor' ),
'selector' => '.site-footer .copyright',
]
);
$this->add_control(
'hello_footer_disable_note',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf(
/* translators: %s: Link that opens the theme settings page. */
__( 'Note: Hiding all the elements, only hides them visually. To disable them completely go to <a href="%s">Theme Settings</a> .', 'hello-elementor' ),
admin_url( 'themes.php?page=hello-theme-settings' )
),
'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
'condition' => [
'hello_footer_logo_display' => '',
'hello_footer_tagline_display' => '',
'hello_footer_menu_display' => '',
'hello_footer_copyright_display' => '',
],
]
);
$this->add_control(
'hello_footer_layout',
[
'type' => Controls_Manager::SELECT,
'label' => esc_html__( 'Layout', 'hello-elementor' ),
'options' => [
'default' => esc_html__( 'Default', 'hello-elementor' ),
'inverted' => esc_html__( 'Inverted', 'hello-elementor' ),
'stacked' => esc_html__( 'Centered', 'hello-elementor' ),
],
'selector' => '.site-footer',
'default' => 'default',
'separator' => 'before',
]
);
$this->add_control(
'hello_footer_width',
[
'type' => Controls_Manager::SELECT,
'label' => esc_html__( 'Width', 'hello-elementor' ),
'options' => [
'boxed' => esc_html__( 'Boxed', 'hello-elementor' ),
'full-width' => esc_html__( 'Full Width', 'hello-elementor' ),
],
'selector' => '.site-footer',
'default' => 'boxed',
]
);
$this->add_responsive_control(
'hello_footer_custom_width',
[
'type' => Controls_Manager::SLIDER,
'label' => esc_html__( 'Content Width', 'hello-elementor' ),
'size_units' => [ '%', 'px', 'em', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'max' => 2000,
],
'em' => [
'max' => 100,
],
'rem' => [
'max' => 100,
],
],
'condition' => [
'hello_footer_width' => 'boxed',
],
'selectors' => [
'.site-footer .footer-inner' => 'width: {{SIZE}}{{UNIT}}; max-width: 100%;',
],
]
);
$this->add_responsive_control(
'hello_footer_gap',
[
'type' => Controls_Manager::SLIDER,
'label' => esc_html__( 'Gap', 'hello-elementor' ),
'size_units' => [ '%', 'px', 'em ', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'max' => 100,
],
'em' => [
'max' => 5,
],
'rem' => [
'max' => 5,
],
],
'selectors' => [
'.site-footer' => 'padding-inline-end: {{SIZE}}{{UNIT}}; padding-inline-start: {{SIZE}}{{UNIT}}',
],
'condition' => [
'hello_footer_layout!' => 'stacked',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'hello_footer_background',
'label' => esc_html__( 'Background', 'hello-elementor' ),
'types' => [ 'classic', 'gradient' ],
'selector' => '.site-footer',
]
);
$this->end_controls_section();
$this->start_controls_section(
'hello_footer_logo_section',
[
'tab' => 'hello-settings-footer',
'label' => esc_html__( 'Site Logo', 'hello-elementor' ),
'condition' => [
'hello_footer_logo_display!' => '',
],
]
);
$this->add_control(
'hello_footer_logo_type',
[
'label' => esc_html__( 'Type', 'hello-elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'logo',
'options' => [
'logo' => esc_html__( 'Logo', 'hello-elementor' ),
'title' => esc_html__( 'Title', 'hello-elementor' ),
],
'frontend_available' => true,
]
);
$this->add_responsive_control(
'hello_footer_logo_width',
[
'type' => Controls_Manager::SLIDER,
'label' => esc_html__( 'Logo Width', 'hello-elementor' ),
'description' => sprintf(
/* translators: %s: Link that opens Elementor's "Site Identity" panel. */
__( 'Go to <a href="%s">Site Identity</a> to manage your site\'s logo', 'hello-elementor' ),
"javascript:\$e.route('panel/global/settings-site-identity')"
),
'size_units' => [ '%', 'px', 'em', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'max' => 1000,
],
'em' => [
'max' => 100,
],
'rem' => [
'max' => 100,
],
],
'condition' => [
'hello_footer_logo_display' => 'yes',
'hello_footer_logo_type' => 'logo',
],
'selectors' => [
'.site-footer .site-branding .site-logo img' => 'width: {{SIZE}}{{UNIT}}; max-width: {{SIZE}}{{UNIT}}',
],
]
);
$this->add_control(
'hello_footer_title_color',
[
'label' => esc_html__( 'Text Color', 'hello-elementor' ),
'type' => Controls_Manager::COLOR,
'condition' => [
'hello_footer_logo_display' => 'yes',
'hello_footer_logo_type' => 'title',
],
'selectors' => [
'.site-footer h4.site-title a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'hello_footer_title_typography',
'label' => esc_html__( 'Typography', 'hello-elementor' ),
'condition' => [
'hello_footer_logo_display' => 'yes',
'hello_footer_logo_type' => 'title',
],
'selector' => '.site-footer h4.site-title',
]
);
$this->add_control(
'hello_footer_title_link',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf(
/* translators: %s: Link that opens Elementor's "Site Identity" panel. */
__( 'Go to <a href="%s">Site Identity</a> to manage your site\'s title', 'hello-elementor' ),
"javascript:\$e.route('panel/global/settings-site-identity')"
),
'content_classes' => 'elementor-control-field-description',
'condition' => [
'hello_footer_logo_display' => 'yes',
'hello_footer_logo_type' => 'title',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'hello_footer_tagline',
[
'tab' => 'hello-settings-footer',
'label' => esc_html__( 'Tagline', 'hello-elementor' ),
'condition' => [
'hello_footer_tagline_display' => 'yes',
],
]
);
$this->add_control(
'hello_footer_tagline_color',
[
'label' => esc_html__( 'Text Color', 'hello-elementor' ),
'type' => Controls_Manager::COLOR,
'condition' => [
'hello_footer_tagline_display' => 'yes',
],
'selectors' => [
'.site-footer .site-description' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'hello_footer_tagline_typography',
'label' => esc_html__( 'Typography', 'hello-elementor' ),
'condition' => [
'hello_footer_tagline_display' => 'yes',
],
'selector' => '.site-footer .site-description',
]
);
$this->add_control(
'hello_footer_tagline_link',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf(
/* translators: %s: Link that opens Elementor's "Site Identity" panel. */
__( 'Go to <a href="%s">Site Identity</a> to manage your site\'s tagline', 'hello-elementor' ),
"javascript:\$e.route('panel/global/settings-site-identity')"
),
'content_classes' => 'elementor-control-field-description',
]
);
$this->end_controls_section();
$this->start_controls_section(
'hello_footer_menu_tab',
[
'tab' => 'hello-settings-footer',
'label' => esc_html__( 'Menu', 'hello-elementor' ),
'condition' => [
'hello_footer_menu_display' => 'yes',
],
]
);
$available_menus = wp_get_nav_menus();
$menus = [ '0' => esc_html__( '— Select a Menu —', 'hello-elementor' ) ];
foreach ( $available_menus as $available_menu ) {
$menus[ $available_menu->term_id ] = $available_menu->name;
}
if ( 1 === count( $menus ) ) {
$this->add_control(
'hello_footer_menu_notice',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => '<strong>' . esc_html__( 'There are no menus in your site.', 'hello-elementor' ) . '</strong><br>' . sprintf( __( 'Go to <a href="%s" target="_blank">Menus screen</a> to create one.', 'hello-elementor' ), admin_url( 'nav-menus.php?action=edit&menu=0' ) ),
'separator' => 'after',
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
]
);
} else {
$this->add_control(
'hello_footer_menu',
[
'label' => esc_html__( 'Menu', 'hello-elementor' ),
'type' => Controls_Manager::SELECT,
'options' => $menus,
'default' => array_keys( $menus )[0],
'description' => sprintf( __( 'Go to the <a href="%s" target="_blank">Menus screen</a> to manage your menus.', 'hello-elementor' ), admin_url( 'nav-menus.php' ) ),
]
);
$this->add_control(
'hello_footer_menu_warning',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => esc_html__( 'Changes will be reflected in the preview only after the page reloads.', 'hello-elementor' ),
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
]
);
$this->add_control(
'hello_footer_menu_color',
[
'label' => esc_html__( 'Color', 'hello-elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'footer .footer-inner .site-navigation a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'hello_footer_menu_typography',
'label' => esc_html__( 'Typography', 'hello-elementor' ),
'selector' => 'footer .footer-inner .site-navigation a',
]
);
}
$this->end_controls_section();
$this->start_controls_section(
'hello_footer_copyright_section',
[
'tab' => 'hello-settings-footer',
'label' => esc_html__( 'Copyright', 'hello-elementor' ),
'conditions' => [
'relation' => 'and',
'terms' => [
[
'name' => 'hello_footer_copyright_display',
'operator' => '=',
'value' => 'yes',
],
],
],
]
);
$this->add_control(
'hello_footer_copyright_text',
[
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__( 'All rights reserved', 'hello-elementor' ),
]
);
$this->add_control(
'hello_footer_copyright_color',
[
'label' => esc_html__( 'Text Color', 'hello-elementor' ),
'type' => Controls_Manager::COLOR,
'condition' => [
'hello_footer_copyright_display' => 'yes',
],
'selectors' => [
'.site-footer .copyright p' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'hello_footer_copyright_typography',
'label' => esc_html__( 'Typography', 'hello-elementor' ),
'condition' => [
'hello_footer_copyright_display' => 'yes',
],
'selector' => '.site-footer .copyright p',
]
);
$this->end_controls_section();
}
public function on_save( $data ) {
// Save chosen footer menu to the WP settings.
if ( isset( $data['settings']['hello_footer_menu'] ) ) {
$menu_id = $data['settings']['hello_footer_menu'];
$locations = get_theme_mod( 'nav_menu_locations' );
$locations['menu-2'] = (int) $menu_id;
set_theme_mod( 'nav_menu_locations', $locations );
}
}
public function get_additional_tab_content() {
$content_template = '
<div class="hello-elementor elementor-nerd-box">
<img src="%1$s" class="elementor-nerd-box-icon" alt="%2$s">
<p class="elementor-nerd-box-title">%3$s</p>
<p class="elementor-nerd-box-message">%4$s</p>
<a class="elementor-nerd-box-link elementor-button" target="_blank" href="%5$s">%6$s</a>
</div>';
if ( ! defined( 'ELEMENTOR_PRO_VERSION' ) ) {
return sprintf(
$content_template,
get_template_directory_uri() . '/assets/images/go-pro.svg',
esc_attr__( 'Get Elementor Pro', 'hello-elementor' ),
esc_html__( 'Create a custom footer with multiple options', 'hello-elementor' ),
esc_html__( 'Upgrade to Elementor Pro and enjoy free design and many more features', 'hello-elementor' ),
'https://go.elementor.com/hello-theme-footer/',
esc_html__( 'Upgrade', 'hello-elementor' )
);
} else {
return sprintf(
$content_template,
get_template_directory_uri() . '/assets/images/go-pro.svg',
esc_attr__( 'Elementor Pro', 'hello-elementor' ),
esc_html__( 'Create a custom footer with the Theme Builder', 'hello-elementor' ),
esc_html__( 'With the Theme Builder you can jump directly into each part of your site', 'hello-elementor' ),
get_admin_url( null, 'admin.php?page=elementor-app#/site-editor/templates/footer' ),
esc_html__( 'Create Footer', 'hello-elementor' )
);
}
}
}

View File

@@ -0,0 +1,554 @@
<?php
namespace HelloElementor\Includes\Settings;
use Elementor\Plugin;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Typography;
use Elementor\Core\Responsive\Responsive;
use Elementor\Core\Kits\Documents\Tabs\Tab_Base;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Settings_Header extends Tab_Base {
public function get_id() {
return 'hello-settings-header';
}
public function get_title() {
return esc_html__( 'Hello Theme Header', 'hello-elementor' );
}
public function get_icon() {
return 'eicon-header';
}
public function get_help_url() {
return '';
}
public function get_group() {
return 'theme-style';
}
protected function register_tab_controls() {
$this->start_controls_section(
'hello_header_section',
[
'tab' => 'hello-settings-header',
'label' => esc_html__( 'Header', 'hello-elementor' ),
]
);
$this->add_control(
'hello_header_logo_display',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Site Logo', 'hello-elementor' ),
'default' => 'yes',
'label_on' => esc_html__( 'Show', 'hello-elementor' ),
'label_off' => esc_html__( 'Hide', 'hello-elementor' ),
]
);
$this->add_control(
'hello_header_tagline_display',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Tagline', 'hello-elementor' ),
'default' => 'yes',
'label_on' => esc_html__( 'Show', 'hello-elementor' ),
'label_off' => esc_html__( 'Hide', 'hello-elementor' ),
]
);
$this->add_control(
'hello_header_menu_display',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Menu', 'hello-elementor' ),
'default' => 'yes',
'label_on' => esc_html__( 'Show', 'hello-elementor' ),
'label_off' => esc_html__( 'Hide', 'hello-elementor' ),
]
);
$this->add_control(
'hello_header_disable_note',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf(
/* translators: %s: Link that opens the theme settings page. */
__( 'Note: Hiding all the elements, only hides them visually. To disable them completely go to <a href="%s">Theme Settings</a> .', 'hello-elementor' ),
admin_url( 'themes.php?page=hello-theme-settings' )
),
'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
'condition' => [
'hello_header_logo_display' => '',
'hello_header_tagline_display' => '',
'hello_header_menu_display' => '',
],
]
);
$this->add_control(
'hello_header_layout',
[
'type' => Controls_Manager::SELECT,
'label' => esc_html__( 'Layout', 'hello-elementor' ),
'options' => [
'default' => esc_html__( 'Default', 'hello-elementor' ),
'inverted' => esc_html__( 'Inverted', 'hello-elementor' ),
'stacked' => esc_html__( 'Centered', 'hello-elementor' ),
],
'selector' => '.site-header',
'default' => 'default',
'separator' => 'before',
]
);
$this->add_control(
'hello_header_width',
[
'type' => Controls_Manager::SELECT,
'label' => esc_html__( 'Width', 'hello-elementor' ),
'options' => [
'boxed' => esc_html__( 'Boxed', 'hello-elementor' ),
'full-width' => esc_html__( 'Full Width', 'hello-elementor' ),
],
'selector' => '.site-header',
'default' => 'boxed',
]
);
$this->add_responsive_control(
'hello_header_custom_width',
[
'type' => Controls_Manager::SLIDER,
'label' => esc_html__( 'Content Width', 'hello-elementor' ),
'size_units' => [ '%', 'px', 'em', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'max' => 2000,
],
'em' => [
'max' => 100,
],
'rem' => [
'max' => 100,
],
],
'condition' => [
'hello_header_width' => 'boxed',
],
'selectors' => [
'.site-header .header-inner' => 'width: {{SIZE}}{{UNIT}}; max-width: 100%;',
],
]
);
$this->add_responsive_control(
'hello_header_gap',
[
'type' => Controls_Manager::SLIDER,
'label' => esc_html__( 'Gap', 'hello-elementor' ),
'size_units' => [ '%', 'px', 'em ', 'rem', 'vw', 'custom' ],
'default' => [
'size' => '0',
],
'range' => [
'px' => [
'max' => 100,
],
'em' => [
'max' => 5,
],
'rem' => [
'max' => 5,
],
],
'selectors' => [
'.site-header' => 'padding-inline-end: {{SIZE}}{{UNIT}}; padding-inline-start: {{SIZE}}{{UNIT}}',
],
'conditions' => [
'relation' => 'and',
'terms' => [
[
'name' => 'hello_header_layout',
'operator' => '!=',
'value' => 'stacked',
],
],
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'hello_header_background',
'label' => esc_html__( 'Background', 'hello-elementor' ),
'types' => [ 'classic', 'gradient' ],
'selector' => '.site-header',
]
);
$this->end_controls_section();
$this->start_controls_section(
'hello_header_logo_section',
[
'tab' => 'hello-settings-header',
'label' => esc_html__( 'Site Logo', 'hello-elementor' ),
'conditions' => [
'relation' => 'and',
'terms' => [
[
'name' => 'hello_header_logo_display',
'operator' => '=',
'value' => 'yes',
],
],
],
]
);
$this->add_control(
'hello_header_logo_type',
[
'label' => esc_html__( 'Type', 'hello-elementor' ),
'type' => Controls_Manager::SELECT,
'default' => ( has_custom_logo() ? 'logo' : 'title' ),
'options' => [
'logo' => esc_html__( 'Logo', 'hello-elementor' ),
'title' => esc_html__( 'Title', 'hello-elementor' ),
],
'frontend_available' => true,
]
);
$this->add_responsive_control(
'hello_header_logo_width',
[
'type' => Controls_Manager::SLIDER,
'label' => esc_html__( 'Logo Width', 'hello-elementor' ),
'description' => sprintf(
/* translators: %s: Link that opens Elementor's "Site Identity" panel. */
__( 'Go to <a href="%s">Site Identity</a> to manage your site\'s logo', 'hello-elementor' ),
"javascript:\$e.route('panel/global/settings-site-identity')"
),
'size_units' => [ '%', 'px', 'em', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'max' => 1000,
],
'em' => [
'max' => 100,
],
'rem' => [
'max' => 100,
],
],
'condition' => [
'hello_header_logo_display' => 'yes',
'hello_header_logo_type' => 'logo',
],
'selectors' => [
'.site-header .site-branding .site-logo img' => 'width: {{SIZE}}{{UNIT}}; max-width: {{SIZE}}{{UNIT}}',
],
]
);
$this->add_control(
'hello_header_title_color',
[
'label' => esc_html__( 'Text Color', 'hello-elementor' ),
'type' => Controls_Manager::COLOR,
'condition' => [
'hello_header_logo_display' => 'yes',
'hello_header_logo_type' => 'title',
],
'selectors' => [
'.site-header h1.site-title a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'hello_header_title_typography',
'label' => esc_html__( 'Typography', 'hello-elementor' ),
'description' => sprintf(
/* translators: %s: Link that opens Elementor's "Site Identity" panel. */
__( 'Go to <a href="%s">Site Identity</a> to manage your site\'s title', 'hello-elementor' ),
"javascript:\$e.route('panel/global/settings-site-identity')"
),
'condition' => [
'hello_header_logo_display' => 'yes',
'hello_header_logo_type' => 'title',
],
'selector' => '.site-header h1.site-title',
]
);
$this->add_control(
'hello_header_title_link',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf(
/* translators: %s: Link that opens Elementor's "Site Identity" panel. */
__( 'Go to <a href="%s">Site Identity</a> to manage your site\'s title', 'hello-elementor' ),
"javascript:\$e.route('panel/global/settings-site-identity')"
),
'content_classes' => 'elementor-control-field-description',
'condition' => [
'hello_header_logo_display' => 'yes',
'hello_header_logo_type' => 'title',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'hello_header_tagline',
[
'tab' => 'hello-settings-header',
'label' => esc_html__( 'Tagline', 'hello-elementor' ),
'conditions' => [
'relation' => 'and',
'terms' => [
[
'name' => 'hello_header_tagline_display',
'operator' => '=',
'value' => 'yes',
],
],
],
]
);
$this->add_control(
'hello_header_tagline_color',
[
'label' => esc_html__( 'Text Color', 'hello-elementor' ),
'type' => Controls_Manager::COLOR,
'condition' => [
'hello_header_tagline_display' => 'yes',
],
'selectors' => [
'.site-header .site-description' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'hello_header_tagline_typography',
'label' => esc_html__( 'Typography', 'hello-elementor' ),
'condition' => [
'hello_header_tagline_display' => 'yes',
],
'selector' => '.site-header .site-description',
]
);
$this->add_control(
'hello_header_tagline_link',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => sprintf(
/* translators: %s: Link that opens Elementor's "Site Identity" panel. */
__( 'Go to <a href="%s">Site Identity</a> to manage your site\'s tagline', 'hello-elementor' ),
"javascript:\$e.route('panel/global/settings-site-identity')"
),
'content_classes' => 'elementor-control-field-description',
]
);
$this->end_controls_section();
$this->start_controls_section(
'hello_header_menu_tab',
[
'tab' => 'hello-settings-header',
'label' => esc_html__( 'Menu', 'hello-elementor' ),
'conditions' => [
'relation' => 'and',
'terms' => [
[
'name' => 'hello_header_menu_display',
'operator' => '=',
'value' => 'yes',
],
],
],
]
);
$available_menus = wp_get_nav_menus();
$menus = [ '0' => esc_html__( '— Select a Menu —', 'hello-elementor' ) ];
foreach ( $available_menus as $available_menu ) {
$menus[ $available_menu->term_id ] = $available_menu->name;
}
if ( 1 === count( $menus ) ) {
$this->add_control(
'hello_header_menu_notice',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => '<strong>' . esc_html__( 'There are no menus in your site.', 'hello-elementor' ) . '</strong><br>' . sprintf( __( 'Go to <a href="%s" target="_blank">Menus screen</a> to create one.', 'hello-elementor' ), admin_url( 'nav-menus.php?action=edit&menu=0' ) ),
'separator' => 'after',
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
]
);
} else {
$this->add_control(
'hello_header_menu',
[
'label' => esc_html__( 'Menu', 'hello-elementor' ),
'type' => Controls_Manager::SELECT,
'options' => $menus,
'default' => array_keys( $menus )[0],
'description' => sprintf( __( 'Go to the <a href="%s" target="_blank">Menus screen</a> to manage your menus.', 'hello-elementor' ), admin_url( 'nav-menus.php' ) ),
]
);
$this->add_control(
'hello_header_menu_warning',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => esc_html__( 'Changes will be reflected in the preview only after the page reloads.', 'hello-elementor' ),
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
]
);
$this->add_control(
'hello_header_menu_layout',
[
'label' => esc_html__( 'Menu Layout', 'hello-elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'horizontal',
'options' => [
'horizontal' => esc_html__( 'Horizontal', 'hello-elementor' ),
'dropdown' => esc_html__( 'Dropdown', 'hello-elementor' ),
],
'frontend_available' => true,
]
);
$breakpoints = Responsive::get_breakpoints();
$this->add_control(
'hello_header_menu_dropdown',
[
'label' => esc_html__( 'Breakpoint', 'hello-elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'tablet',
'options' => [
/* translators: %d: Breakpoint number. */
'mobile' => sprintf( esc_html__( 'Mobile (< %dpx)', 'hello-elementor' ), $breakpoints['md'] ),
/* translators: %d: Breakpoint number. */
'tablet' => sprintf( esc_html__( 'Tablet (< %dpx)', 'hello-elementor' ), $breakpoints['lg'] ),
'none' => esc_html__( 'None', 'hello-elementor' ),
],
'selector' => '.site-header',
'condition' => [
'hello_header_menu_layout!' => 'dropdown',
],
]
);
$this->add_control(
'hello_header_menu_color',
[
'label' => esc_html__( 'Color', 'hello-elementor' ),
'type' => Controls_Manager::COLOR,
'condition' => [
'hello_header_menu_display' => 'yes',
],
'selectors' => [
'.site-header .site-navigation ul.menu li a' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'hello_header_menu_toggle_color',
[
'label' => esc_html__( 'Toggle Color', 'hello-elementor' ),
'type' => Controls_Manager::COLOR,
'condition' => [
'hello_header_menu_display' => 'yes',
],
'selectors' => [
'.site-header .site-navigation-toggle i' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'hello_header_menu_typography',
'label' => esc_html__( 'Typography', 'hello-elementor' ),
'condition' => [
'hello_header_menu_display' => 'yes',
],
'selector' => '.site-header .site-navigation .menu li',
]
);
}
$this->end_controls_section();
}
public function on_save( $data ) {
// Save chosen header menu to the WP settings.
if ( isset( $data['settings']['hello_header_menu'] ) ) {
$menu_id = $data['settings']['hello_header_menu'];
$locations = get_theme_mod( 'nav_menu_locations' );
$locations['menu-1'] = (int) $menu_id;
set_theme_mod( 'nav_menu_locations', $locations );
}
}
public function get_additional_tab_content() {
$content_template = '
<div class="hello-elementor elementor-nerd-box">
<img src="%1$s" class="elementor-nerd-box-icon" alt="%2$s">
<p class="elementor-nerd-box-title">%3$s</p>
<p class="elementor-nerd-box-message">%4$s</p>
<a class="elementor-nerd-box-link elementor-button" target="_blank" href="%5$s">%6$s</a>
</div>';
if ( ! defined( 'ELEMENTOR_PRO_VERSION' ) ) {
return sprintf(
$content_template,
get_template_directory_uri() . '/assets/images/go-pro.svg',
esc_attr__( 'Get Elementor Pro', 'hello-elementor' ),
esc_html__( 'Create a custom header with multiple options', 'hello-elementor' ),
esc_html__( 'Upgrade to Elementor Pro and enjoy free design and many more features', 'hello-elementor' ),
'https://go.elementor.com/hello-theme-header/',
esc_html__( 'Upgrade', 'hello-elementor' )
);
} else {
return sprintf(
$content_template,
get_template_directory_uri() . '/assets/images/go-pro.svg',
esc_attr__( 'Elementor Pro', 'hello-elementor' ),
esc_html__( 'Create a custom header with the Theme Builder', 'hello-elementor' ),
esc_html__( 'With the Theme Builder you can jump directly into each part of your site', 'hello-elementor' ),
get_admin_url( null, 'admin.php?page=elementor-app#/site-editor/templates/header' ),
esc_html__( 'Create Header', 'hello-elementor' )
);
}
}
}