first commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Customizer controls for header & footer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function hello_customizer_register( $wp_customize ) {
|
||||
require_once 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' );
|
||||
|
||||
/**
|
||||
* Register Customizer controls for Elementor Pro upsell.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function hello_customizer_register_elementor_pro_upsell( $wp_customize ) {
|
||||
if ( function_exists( 'elementor_pro_load_plugin' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once get_template_directory() . '/includes/customizer/customizer-upsell.php';
|
||||
|
||||
$wp_customize->add_section(
|
||||
new HelloElementor\Includes\Customizer\Hello_Customizer_Upsell(
|
||||
$wp_customize,
|
||||
'hello-upsell-elementor-pro',
|
||||
[
|
||||
'heading' => esc_html__( 'Customize your entire website with Elementor Pro', 'hello-elementor' ),
|
||||
'description' => esc_html__( 'Build and customize every part of your website, including Theme Parts with Elementor Pro.', 'hello-elementor' ),
|
||||
'button_text' => esc_html__( 'Upgrade Now', 'hello-elementor' ),
|
||||
'button_url' => 'https://elementor.com/pro/?utm_source=hello-theme-customize&utm_campaign=gopro&utm_medium=wp-dash',
|
||||
'priority' => 999999,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'customize_register', 'hello_customizer_register_elementor_pro_upsell' );
|
||||
|
||||
/**
|
||||
* Enqueue Customizer CSS.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function hello_customizer_styles() {
|
||||
wp_enqueue_style(
|
||||
'hello-elementor-customizer',
|
||||
HELLO_THEME_STYLE_URL . 'customizer.css',
|
||||
[],
|
||||
HELLO_ELEMENTOR_VERSION
|
||||
);
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'hello_customizer_styles' );
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
namespace HelloElementor\Includes\Customizer;
|
||||
|
||||
use HelloTheme\Includes\Utils;
|
||||
|
||||
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 = Utils::get_action_link_type();
|
||||
|
||||
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 Elementor’s "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 Elementor’s "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'],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace HelloElementor\Includes\Customizer;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Hello_Customizer_Upsell extends \WP_Customize_Section {
|
||||
|
||||
public $heading;
|
||||
|
||||
public $description;
|
||||
|
||||
public $button_text;
|
||||
|
||||
public $button_url;
|
||||
|
||||
/**
|
||||
* Render the section, and the controls that have been added to it.
|
||||
*/
|
||||
protected function render() {
|
||||
?>
|
||||
<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="accordion-section control-section control-section-<?php echo esc_attr( $this->id ); ?> cannot-expand">
|
||||
<h3 class="accordion-section-title"><?php echo esc_html( $this->heading ); ?></h3>
|
||||
<p class="accordion-section-description"><?php echo esc_html( $this->description ); ?></p>
|
||||
<div class="accordion-section-buttons">
|
||||
<a href="<?php echo esc_url( $this->button_url ); ?>" target="_blank"><?php echo esc_html( $this->button_text ); ?></a>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?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',
|
||||
HELLO_THEME_SCRIPTS_URL . 'hello-editor.js',
|
||||
[ 'jquery', 'elementor-editor' ],
|
||||
HELLO_ELEMENTOR_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'hello-editor',
|
||||
HELLO_THEME_STYLE_URL . 'editor.css',
|
||||
[],
|
||||
HELLO_ELEMENTOR_VERSION
|
||||
);
|
||||
} );
|
||||
|
||||
add_action( 'wp_enqueue_scripts', function() {
|
||||
if ( ! hello_elementor_display_header_footer() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! hello_header_footer_experiment_active() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_script(
|
||||
'hello-theme-frontend',
|
||||
HELLO_THEME_SCRIPTS_URL . 'hello-frontend.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__( 'Header & Footer', 'hello-elementor' ),
|
||||
'tag' => esc_html__( 'Hello Theme', 'hello-elementor' ),
|
||||
'description' => sprintf(
|
||||
'%1$s <a href="%2$s" target="_blank">%3$s</a>',
|
||||
esc_html__( 'Customize and style the builtin Hello Theme’s 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' ) );
|
||||
}
|
||||
284
wp-content/themes/hello-elementor/includes/module-base.php
Normal file
284
wp-content/themes/hello-elementor/includes/module-base.php
Normal file
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
|
||||
namespace HelloTheme\Includes;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Module Base.
|
||||
*
|
||||
* An abstract class providing the properties and methods needed to
|
||||
* manage and handle modules in inheriting classes.
|
||||
*
|
||||
* @abstract
|
||||
* @package HelloTheme
|
||||
* @subpackage HelloThemeModules
|
||||
*/
|
||||
abstract class Module_Base {
|
||||
|
||||
/**
|
||||
* Module class reflection.
|
||||
*
|
||||
* Holds the information about a class.
|
||||
* @access private
|
||||
*
|
||||
* @var ?\ReflectionClass
|
||||
*/
|
||||
private ?\ReflectionClass $reflection = null;
|
||||
|
||||
/**
|
||||
* Module components.
|
||||
*
|
||||
* Holds the module components.
|
||||
* @access private
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private array $components = [];
|
||||
|
||||
/**
|
||||
* Module instance.
|
||||
*
|
||||
* Holds the module instance.
|
||||
* @access protected
|
||||
*
|
||||
* @var Module_Base[]
|
||||
*/
|
||||
protected static array $instances = [];
|
||||
|
||||
/**
|
||||
* Get module name.
|
||||
*
|
||||
* Retrieve the module name.
|
||||
* @access public
|
||||
* @abstract
|
||||
*
|
||||
* @return string Module name.
|
||||
*/
|
||||
abstract public static function get_name(): string;
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @access protected
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
abstract protected function get_component_ids(): array;
|
||||
|
||||
/**
|
||||
* Singleton Instance.
|
||||
*
|
||||
* Ensures only one instance of the module class is loaded or can be loaded.
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return Module_Base An instance of the class.
|
||||
*/
|
||||
public static function instance(): Module_Base {
|
||||
$class_name = static::class_name();
|
||||
|
||||
if ( empty( static::$instances[ $class_name ] ) ) {
|
||||
static::$instances[ $class_name ] = new static(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return static::$instances[ $class_name ];
|
||||
}
|
||||
|
||||
/**
|
||||
* is_active
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_active(): bool {
|
||||
/**
|
||||
* allow enabling/disabling the module on run-time
|
||||
*
|
||||
* @param bool $is_active the filters value
|
||||
*/
|
||||
return apply_filters( 'hello-plus-theme/modules/' . static::get_name() . '/is-active', true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* Retrieve the name of the class.
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
public static function class_name(): string {
|
||||
return get_called_class();
|
||||
}
|
||||
|
||||
/**
|
||||
* @access public
|
||||
*
|
||||
* @return \ReflectionClass
|
||||
*/
|
||||
public function get_reflection(): \ReflectionClass {
|
||||
if ( null === $this->reflection ) {
|
||||
try {
|
||||
$this->reflection = new \ReflectionClass( $this );
|
||||
} catch ( \ReflectionException $e ) {
|
||||
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||
error_log( $e->getMessage() ); //phpcs:ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->reflection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add module component.
|
||||
*
|
||||
* Add new component to the current module.
|
||||
* @access public
|
||||
*
|
||||
* @param string $id Component ID.
|
||||
* @param mixed $instance An instance of the component.
|
||||
*/
|
||||
public function add_component( string $id, $instance ) {
|
||||
$this->components[ $id ] = $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @access public
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_components(): array {
|
||||
return $this->components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module component.
|
||||
*
|
||||
* Retrieve the module component.
|
||||
* @access public
|
||||
*
|
||||
* @param string $id Component ID.
|
||||
*
|
||||
* @return mixed An instance of the component, or `null` if the component
|
||||
* doesn't exist.
|
||||
*/
|
||||
public function get_component( string $id ) {
|
||||
if ( isset( $this->components[ $id ] ) ) {
|
||||
return $this->components[ $id ];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the namespace of the class
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function namespace_name(): string {
|
||||
$class_name = static::class_name();
|
||||
return substr( $class_name, 0, strrpos( $class_name, '\\' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an array of components.
|
||||
* Assumes namespace structure contains `\Components\`
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @param ?array $components_ids => component's class name.
|
||||
* @return void
|
||||
*/
|
||||
protected function register_components( ?array $components_ids = null ): void {
|
||||
if ( empty( $components_ids ) ) {
|
||||
$components_ids = $this->get_component_ids();
|
||||
}
|
||||
$namespace = static::namespace_name();
|
||||
foreach ( $components_ids as $component_id ) {
|
||||
$class_name = $namespace . '\\Components\\' . $component_id;
|
||||
$this->add_component( $component_id, new $class_name() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the Module's widgets.
|
||||
* Assumes namespace structure contains `\Widgets\`
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @param \Elementor\Widgets_Manager $widgets_manager
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets( \Elementor\Widgets_Manager $widgets_manager ): void {
|
||||
$widget_ids = $this->get_widget_ids();
|
||||
$namespace = static::namespace_name();
|
||||
|
||||
foreach ( $widget_ids as $widget_id ) {
|
||||
$class_name = $namespace . '\\Widgets\\' . $widget_id;
|
||||
$widgets_manager->register( new $class_name() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function get_widget_ids(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function register_hooks(): void {
|
||||
add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone.
|
||||
*
|
||||
* Disable class cloning and throw an error on object clone.
|
||||
*
|
||||
* The whole idea of the singleton design pattern is that there is a single
|
||||
* object. Therefore, we don't want the object to be cloned.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
public function __clone() {
|
||||
// Cloning instances of the class is forbidden
|
||||
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'hello-elementor' ), '0.0.1' ); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/**
|
||||
* Wakeup.
|
||||
*
|
||||
* Disable un-serializing of the class.
|
||||
* @access public
|
||||
*/
|
||||
public function __wakeup() {
|
||||
// Un-serializing instances of the class is forbidden
|
||||
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'hello-elementor' ), '0.0.1' ); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/**
|
||||
* class constructor
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @param ?string[] $components_list
|
||||
*/
|
||||
protected function __construct( ?array $components_list = null ) {
|
||||
$this->register_components( $components_list );
|
||||
$this->register_hooks();
|
||||
}
|
||||
}
|
||||
43
wp-content/themes/hello-elementor/includes/script.php
Normal file
43
wp-content/themes/hello-elementor/includes/script.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace HelloTheme\Includes;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Script {
|
||||
|
||||
protected string $handle;
|
||||
protected array $dependencies;
|
||||
|
||||
public function __construct( string $handle, array $dependencies = [] ) {
|
||||
$this->handle = $handle;
|
||||
$this->dependencies = $dependencies;
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
$asset_path = HELLO_THEME_SCRIPTS_PATH . $this->handle . '.asset.php';
|
||||
$asset_url = HELLO_THEME_SCRIPTS_URL;
|
||||
|
||||
if ( ! file_exists( $asset_path ) ) {
|
||||
throw new \Exception( $asset_path . ' - You need to run `npm run build` for the "hello-elementor" first.' );
|
||||
}
|
||||
|
||||
$script_asset = require $asset_path;
|
||||
|
||||
foreach ( $this->dependencies as $dependency ) {
|
||||
$script_asset['dependencies'][] = $dependency;
|
||||
}
|
||||
|
||||
wp_enqueue_script(
|
||||
$this->handle,
|
||||
$asset_url . "$this->handle.js",
|
||||
$script_asset['dependencies'],
|
||||
$script_asset['version'],
|
||||
true
|
||||
);
|
||||
|
||||
\wp_set_script_translations( $this->handle, 'hello-elementor' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
use HelloTheme\Theme;
|
||||
use HelloTheme\Modules\AdminHome\Components\Settings_Controller;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
add_action( 'init', 'hello_elementor_tweak_settings', 0 );
|
||||
|
||||
function hello_elementor_tweak_settings() {
|
||||
/**
|
||||
* @var Settings_Controller $settings_controller
|
||||
*/
|
||||
$settings_controller = Theme::instance()
|
||||
->get_module( 'AdminHome' )
|
||||
->get_component( 'Settings_Controller' );
|
||||
|
||||
$settings_controller->legacy_register_settings();
|
||||
}
|
||||
/**
|
||||
* Register a new setting.
|
||||
*
|
||||
* @deprecated 3.4.0
|
||||
*/
|
||||
function hello_elementor_register_settings( $settings_group, $settings ) {
|
||||
/**
|
||||
* @var Settings_Controller $settings_controller
|
||||
*/
|
||||
$settings_controller = Theme::instance()
|
||||
->get_module( 'AdminHome' )
|
||||
->get_component( 'Settings_Controller' );
|
||||
|
||||
$settings_controller->register_settings( $settings_group, $settings );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a tweek only if the user requested it.
|
||||
*
|
||||
* @deprecated 3.4.0
|
||||
*/
|
||||
function hello_elementor_do_tweak( $setting, $tweak_callback ) {
|
||||
/**
|
||||
* @var Settings_Controller $settings_controller
|
||||
*/
|
||||
$settings_controller = Theme::instance()
|
||||
->get_module( 'AdminHome' )
|
||||
->get_component( 'Settings_Controller' );
|
||||
|
||||
$settings_controller->apply_setting( $setting, $tweak_callback );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render theme tweaks.
|
||||
*
|
||||
* @deprecated 3.4.0
|
||||
*/
|
||||
function hello_elementor_render_tweaks( $settings_group, $settings ) {
|
||||
/**
|
||||
* @var Settings_Controller $settings_controller
|
||||
*/
|
||||
$settings_controller = Theme::instance()
|
||||
->get_module( 'AdminHome' )
|
||||
->get_component( 'Settings_Controller' );
|
||||
|
||||
$settings_controller->apply_settings( $settings_group, $settings );
|
||||
}
|
||||
@@ -0,0 +1,756 @@
|
||||
<?php
|
||||
|
||||
namespace HelloElementor\Includes\Settings;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Group_Control_Background;
|
||||
use Elementor\Group_Control_Text_Shadow;
|
||||
use Elementor\Group_Control_Text_Stroke;
|
||||
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() {
|
||||
$start = is_rtl() ? 'right' : 'left';
|
||||
$end = ! is_rtl() ? 'right' : 'left';
|
||||
|
||||
$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::ALERT,
|
||||
'alert_type' => 'warning',
|
||||
'content' => 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' )
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
'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::CHOOSE,
|
||||
'label' => esc_html__( 'Layout', 'hello-elementor' ),
|
||||
'options' => [
|
||||
'inverted' => [
|
||||
'title' => esc_html__( 'Inverted', 'hello-elementor' ),
|
||||
'icon' => "eicon-arrow-$start",
|
||||
],
|
||||
'stacked' => [
|
||||
'title' => esc_html__( 'Centered', 'hello-elementor' ),
|
||||
'icon' => 'eicon-h-align-center',
|
||||
],
|
||||
'default' => [
|
||||
'title' => esc_html__( 'Default', 'hello-elementor' ),
|
||||
'icon' => "eicon-arrow-$end",
|
||||
],
|
||||
],
|
||||
'toggle' => false,
|
||||
'selector' => '.site-footer',
|
||||
'default' => 'default',
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'hello_footer_tagline_position',
|
||||
[
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'label' => esc_html__( 'Tagline Position', 'hello-elementor' ),
|
||||
'options' => [
|
||||
'before' => [
|
||||
'title' => esc_html__( 'Before', 'hello-elementor' ),
|
||||
'icon' => "eicon-arrow-$start",
|
||||
],
|
||||
'below' => [
|
||||
'title' => esc_html__( 'Below', 'hello-elementor' ),
|
||||
'icon' => 'eicon-arrow-down',
|
||||
],
|
||||
'after' => [
|
||||
'title' => esc_html__( 'After', 'hello-elementor' ),
|
||||
'icon' => "eicon-arrow-$end",
|
||||
],
|
||||
],
|
||||
'toggle' => false,
|
||||
'default' => 'below',
|
||||
'selectors_dictionary' => [
|
||||
'before' => 'flex-direction: row-reverse; align-items: center;',
|
||||
'below' => 'flex-direction: column; align-items: stretch;',
|
||||
'after' => 'flex-direction: row; align-items: center;',
|
||||
],
|
||||
'condition' => [
|
||||
'hello_footer_tagline_display' => 'yes',
|
||||
'hello_footer_logo_display' => 'yes',
|
||||
],
|
||||
'selectors' => [
|
||||
'.site-footer .site-branding' => '{{VALUE}}',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'hello_footer_tagline_gap',
|
||||
[
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'label' => esc_html__( 'Tagline Gap', 'hello-elementor' ),
|
||||
'size_units' => [ 'px', 'em ', 'rem', 'custom' ],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'max' => 100,
|
||||
],
|
||||
'em' => [
|
||||
'max' => 10,
|
||||
],
|
||||
'rem' => [
|
||||
'max' => 10,
|
||||
],
|
||||
],
|
||||
'condition' => [
|
||||
'hello_footer_tagline_display' => 'yes',
|
||||
'hello_footer_logo_display' => 'yes',
|
||||
],
|
||||
'selectors' => [
|
||||
'.site-footer .site-branding' => 'gap: {{SIZE}}{{UNIT}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$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',
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$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__( 'Side Margins', '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' ],
|
||||
'separator' => 'before',
|
||||
'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_link',
|
||||
[
|
||||
'type' => Controls_Manager::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'content' => 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')"
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
'condition' => [
|
||||
'hello_footer_logo_display' => 'yes',
|
||||
'hello_footer_logo_type' => 'logo',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_footer_title_link',
|
||||
[
|
||||
'type' => Controls_Manager::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'content' => 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')"
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
'condition' => [
|
||||
'hello_footer_logo_display' => 'yes',
|
||||
'hello_footer_logo_type' => 'title',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$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' ),
|
||||
'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_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 .site-title',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Text_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'hello_footer_title_text_shadow',
|
||||
'label' => esc_html__( 'Text Shadow', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_footer_logo_display' => 'yes',
|
||||
'hello_footer_logo_type' => 'title',
|
||||
],
|
||||
'selector' => '.site-footer .site-title a',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Text_Stroke::get_type(),
|
||||
[
|
||||
'name' => 'hello_footer_title_text_stroke',
|
||||
'label' => esc_html__( 'Text Stroke', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_footer_logo_display' => 'yes',
|
||||
'hello_footer_logo_type' => 'title',
|
||||
],
|
||||
'selector' => '.site-footer .site-title a',
|
||||
]
|
||||
);
|
||||
|
||||
$this->start_controls_tabs( 'hello_footer_title_colors' );
|
||||
|
||||
$this->start_controls_tab(
|
||||
'hello_footer_title_colors_normal',
|
||||
[
|
||||
'label' => esc_html__( 'Normal', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_footer_logo_display' => 'yes',
|
||||
'hello_footer_logo_type' => 'title',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$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 .site-title a' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->start_controls_tab(
|
||||
'hello_footer_title_colors_hover',
|
||||
[
|
||||
'label' => esc_html__( 'Hover', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_footer_logo_display' => 'yes',
|
||||
'hello_footer_logo_type' => 'title',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_footer_title_hover_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 .site-title a:hover' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_footer_title_hover_color_transition_duration',
|
||||
[
|
||||
'label' => esc_html__( 'Transition Duration', 'hello-elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'size_units' => [ 's', 'ms', 'custom' ],
|
||||
'default' => [
|
||||
'unit' => 's',
|
||||
],
|
||||
'selectors' => [
|
||||
'.site-footer .site-title a' => 'transition-duration: {{SIZE}}{{UNIT}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->end_controls_tabs();
|
||||
|
||||
$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_link',
|
||||
[
|
||||
'type' => Controls_Manager::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'content' => 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')"
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
'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_group_control(
|
||||
Group_Control_Text_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'hello_footer_tagline_text_shadow',
|
||||
'label' => esc_html__( 'Text Shadow', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_footer_tagline_display' => 'yes',
|
||||
],
|
||||
'selector' => '.site-footer .site-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::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'heading' => esc_html__( 'There are no menus in your site.', 'hello-elementor' ),
|
||||
'content' => 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' )
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->add_control(
|
||||
'hello_footer_menu_warning',
|
||||
[
|
||||
'type' => Controls_Manager::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'content' => sprintf(
|
||||
__( 'Go to the <a href="%s" target="_blank">Menus screen</a> to manage your menus. Changes will be reflected in the preview only after the page reloads.', 'hello-elementor' ),
|
||||
admin_url( 'nav-menus.php' )
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_footer_menu',
|
||||
[
|
||||
'label' => esc_html__( 'Menu', 'hello-elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => $menus,
|
||||
'default' => array_keys( $menus )[0],
|
||||
]
|
||||
);
|
||||
|
||||
$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->add_group_control(
|
||||
Group_Control_Text_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'hello_footer_menu_text_shadow',
|
||||
'label' => esc_html__( 'Text Shadow', '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,
|
||||
'label' => esc_html__( 'Text', 'hello-elementor' ),
|
||||
'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->add_group_control(
|
||||
Group_Control_Text_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'hello_footer_copyright_text_shadow',
|
||||
'label' => esc_html__( 'Text Shadow', '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 go-pro" 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 custom footers', 'hello-elementor' ),
|
||||
esc_html__( 'Adjust your footer to include contact forms, sitemaps and more with Elementor Pro.', 'hello-elementor' ),
|
||||
'https://go.elementor.com/hello-theme-footer/',
|
||||
esc_html__( 'Upgrade Now', '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' )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,789 @@
|
||||
<?php
|
||||
|
||||
namespace HelloElementor\Includes\Settings;
|
||||
|
||||
use Elementor\Plugin;
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Group_Control_Background;
|
||||
use Elementor\Group_Control_Text_Shadow;
|
||||
use Elementor\Group_Control_Text_Stroke;
|
||||
use Elementor\Group_Control_Typography;
|
||||
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() {
|
||||
$start = is_rtl() ? 'right' : 'left';
|
||||
$end = ! is_rtl() ? 'right' : 'left';
|
||||
|
||||
$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::ALERT,
|
||||
'alert_type' => 'warning',
|
||||
'content' => 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' )
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
'condition' => [
|
||||
'hello_header_logo_display' => '',
|
||||
'hello_header_tagline_display' => '',
|
||||
'hello_header_menu_display' => '',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_header_layout',
|
||||
[
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'label' => esc_html__( 'Layout', 'hello-elementor' ),
|
||||
'options' => [
|
||||
'inverted' => [
|
||||
'title' => esc_html__( 'Inverted', 'hello-elementor' ),
|
||||
'icon' => "eicon-arrow-$start",
|
||||
],
|
||||
'stacked' => [
|
||||
'title' => esc_html__( 'Centered', 'hello-elementor' ),
|
||||
'icon' => 'eicon-h-align-center',
|
||||
],
|
||||
'default' => [
|
||||
'title' => esc_html__( 'Default', 'hello-elementor' ),
|
||||
'icon' => "eicon-arrow-$end",
|
||||
],
|
||||
],
|
||||
'toggle' => false,
|
||||
'selector' => '.site-header',
|
||||
'default' => 'default',
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'hello_header_tagline_position',
|
||||
[
|
||||
'type' => Controls_Manager::CHOOSE,
|
||||
'label' => esc_html__( 'Tagline Position', 'hello-elementor' ),
|
||||
'options' => [
|
||||
'before' => [
|
||||
'title' => esc_html__( 'Before', 'hello-elementor' ),
|
||||
'icon' => "eicon-arrow-$start",
|
||||
],
|
||||
'below' => [
|
||||
'title' => esc_html__( 'Below', 'hello-elementor' ),
|
||||
'icon' => 'eicon-arrow-down',
|
||||
],
|
||||
'after' => [
|
||||
'title' => esc_html__( 'After', 'hello-elementor' ),
|
||||
'icon' => "eicon-arrow-$end",
|
||||
],
|
||||
],
|
||||
'toggle' => false,
|
||||
'default' => 'below',
|
||||
'selectors_dictionary' => [
|
||||
'before' => 'flex-direction: row-reverse; align-items: center;',
|
||||
'below' => 'flex-direction: column; align-items: stretch;',
|
||||
'after' => 'flex-direction: row; align-items: center;',
|
||||
],
|
||||
'condition' => [
|
||||
'hello_header_tagline_display' => 'yes',
|
||||
'hello_header_logo_display' => 'yes',
|
||||
],
|
||||
'selectors' => [
|
||||
'.site-header .site-branding' => '{{VALUE}}',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_responsive_control(
|
||||
'hello_header_tagline_gap',
|
||||
[
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'label' => esc_html__( 'Tagline Gap', 'hello-elementor' ),
|
||||
'size_units' => [ 'px', 'em ', 'rem', 'custom' ],
|
||||
'range' => [
|
||||
'px' => [
|
||||
'max' => 100,
|
||||
],
|
||||
'em' => [
|
||||
'max' => 10,
|
||||
],
|
||||
'rem' => [
|
||||
'max' => 10,
|
||||
],
|
||||
],
|
||||
'condition' => [
|
||||
'hello_header_tagline_display' => 'yes',
|
||||
'hello_header_logo_display' => 'yes',
|
||||
],
|
||||
'selectors' => [
|
||||
'.site-header .site-branding' => 'gap: {{SIZE}}{{UNIT}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$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',
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$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__( 'Side Margins', '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' ],
|
||||
'separator' => 'before',
|
||||
'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_link',
|
||||
[
|
||||
'type' => Controls_Manager::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'content' => 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')"
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
'condition' => [
|
||||
'hello_header_logo_display' => 'yes',
|
||||
'hello_header_logo_type' => 'logo',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_header_title_link',
|
||||
[
|
||||
'type' => Controls_Manager::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'content' => 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')"
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
'condition' => [
|
||||
'hello_header_logo_display' => 'yes',
|
||||
'hello_header_logo_type' => 'title',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$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' ),
|
||||
'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_group_control(
|
||||
Group_Control_Typography::get_type(),
|
||||
[
|
||||
'name' => 'hello_header_title_typography',
|
||||
'label' => esc_html__( 'Typography', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_header_logo_display' => 'yes',
|
||||
'hello_header_logo_type' => 'title',
|
||||
],
|
||||
'selector' => '.site-header .site-title',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Text_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'hello_header_title_text_shadow',
|
||||
'label' => esc_html__( 'Text Shadow', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_header_logo_display' => 'yes',
|
||||
'hello_header_logo_type' => 'title',
|
||||
],
|
||||
'selector' => '.site-header .site-title a',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_group_control(
|
||||
Group_Control_Text_Stroke::get_type(),
|
||||
[
|
||||
'name' => 'hello_header_title_text_stroke',
|
||||
'label' => esc_html__( 'Text Stroke', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_header_logo_display' => 'yes',
|
||||
'hello_header_logo_type' => 'title',
|
||||
],
|
||||
'selector' => '.site-header .site-title a',
|
||||
]
|
||||
);
|
||||
|
||||
$this->start_controls_tabs( 'hello_header_title_colors' );
|
||||
|
||||
$this->start_controls_tab(
|
||||
'hello_header_title_colors_normal',
|
||||
[
|
||||
'label' => esc_html__( 'Normal', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_header_logo_display' => 'yes',
|
||||
'hello_header_logo_type' => 'title',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$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 .site-title a' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->start_controls_tab(
|
||||
'hello_header_title_colors_hover',
|
||||
[
|
||||
'label' => esc_html__( 'Hover', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_header_logo_display' => 'yes',
|
||||
'hello_header_logo_type' => 'title',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_header_title_hover_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 .site-title a:hover' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_header_title_hover_color_transition_duration',
|
||||
[
|
||||
'label' => esc_html__( 'Transition Duration', 'hello-elementor' ),
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'size_units' => [ 's', 'ms', 'custom' ],
|
||||
'default' => [
|
||||
'unit' => 's',
|
||||
],
|
||||
'selectors' => [
|
||||
'.site-header .site-title a' => 'transition-duration: {{SIZE}}{{UNIT}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->end_controls_tab();
|
||||
|
||||
$this->end_controls_tabs();
|
||||
|
||||
$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_link',
|
||||
[
|
||||
'type' => Controls_Manager::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'content' => 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')"
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
'condition' => [
|
||||
'hello_header_tagline_display' => '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_group_control(
|
||||
Group_Control_Text_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'hello_header_tagline_text_shadow',
|
||||
'label' => esc_html__( 'Text Shadow', 'hello-elementor' ),
|
||||
'condition' => [
|
||||
'hello_header_tagline_display' => 'yes',
|
||||
],
|
||||
'selector' => '.site-header .site-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::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'heading' => esc_html__( 'There are no menus in your site.', 'hello-elementor' ),
|
||||
'content' => 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' )
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$this->add_control(
|
||||
'hello_header_menu_warning',
|
||||
[
|
||||
'type' => Controls_Manager::ALERT,
|
||||
'alert_type' => 'info',
|
||||
'content' => sprintf(
|
||||
__( 'Go to the <a href="%s" target="_blank">Menus screen</a> to manage your menus. Changes will be reflected in the preview only after the page reloads.', 'hello-elementor' ),
|
||||
admin_url( 'nav-menus.php' )
|
||||
),
|
||||
'render_type' => 'ui',
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_header_menu',
|
||||
[
|
||||
'label' => esc_html__( 'Menu', 'hello-elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'options' => $menus,
|
||||
'default' => array_keys( $menus )[0],
|
||||
]
|
||||
);
|
||||
|
||||
$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,
|
||||
]
|
||||
);
|
||||
|
||||
$dropdown_options = [];
|
||||
$active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints();
|
||||
$selected_breakpoints = [ 'mobile', 'tablet' ];
|
||||
|
||||
foreach ( $active_breakpoints as $breakpoint_key => $breakpoint_instance ) {
|
||||
if ( ! in_array( $breakpoint_key, $selected_breakpoints, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dropdown_options[ $breakpoint_key ] = sprintf(
|
||||
/* translators: 1: Breakpoint label, 2: Breakpoint value. */
|
||||
esc_html__( '%1$s (> %2$dpx)', 'hello-elementor' ),
|
||||
$breakpoint_instance->get_label(),
|
||||
$breakpoint_instance->get_value()
|
||||
);
|
||||
}
|
||||
|
||||
$dropdown_options['none'] = esc_html__( 'None', 'hello-elementor' );
|
||||
|
||||
$this->add_control(
|
||||
'hello_header_menu_dropdown',
|
||||
[
|
||||
'label' => esc_html__( 'Breakpoint', 'hello-elementor' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => 'tablet',
|
||||
'options' => $dropdown_options,
|
||||
'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 .site-navigation-toggle-icon' => 'color: {{VALUE}};',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_control(
|
||||
'hello_header_menu_toggle_background_color',
|
||||
[
|
||||
'label' => esc_html__( 'Toggle Background Color', 'hello-elementor' ),
|
||||
'type' => Controls_Manager::COLOR,
|
||||
'condition' => [
|
||||
'hello_header_menu_display' => 'yes',
|
||||
],
|
||||
'selectors' => [
|
||||
'.site-header .site-navigation-toggle' => 'background-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->add_group_control(
|
||||
Group_Control_Text_Shadow::get_type(),
|
||||
[
|
||||
'name' => 'hello_header_menu_text_shadow',
|
||||
'label' => esc_html__( 'Text Shadow', '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 go-pro" 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 custom headers', 'hello-elementor' ),
|
||||
esc_html__( 'Add mega menus, search bars, login buttons and more with Elementor Pro.', 'hello-elementor' ),
|
||||
'https://go.elementor.com/hello-theme-header/',
|
||||
esc_html__( 'Upgrade Now', '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' )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
115
wp-content/themes/hello-elementor/includes/utils.php
Normal file
115
wp-content/themes/hello-elementor/includes/utils.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace HelloTheme\Includes;
|
||||
|
||||
use Elementor\App\App;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* class Utils
|
||||
**/
|
||||
class Utils {
|
||||
|
||||
public static function elementor(): \Elementor\Plugin {
|
||||
return \Elementor\Plugin::$instance;
|
||||
}
|
||||
|
||||
public static function has_pro(): bool {
|
||||
return defined( 'ELEMENTOR_PRO_VERSION' );
|
||||
}
|
||||
|
||||
public static function is_elementor_active(): bool {
|
||||
static $elementor_active = null;
|
||||
if ( null === $elementor_active ) {
|
||||
$elementor_active = defined( 'ELEMENTOR_VERSION' );
|
||||
}
|
||||
|
||||
return $elementor_active;
|
||||
}
|
||||
|
||||
public static function is_elementor_installed(): bool {
|
||||
static $elementor_installed = null;
|
||||
if ( null === $elementor_installed ) {
|
||||
$elementor_installed = file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' );
|
||||
}
|
||||
|
||||
return $elementor_installed;
|
||||
}
|
||||
|
||||
public static function get_theme_builder_slug(): string {
|
||||
if ( ! class_exists( 'Elementor\App\App' ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( self::has_pro() ) {
|
||||
return App::PAGE_ID . '&ver=' . ELEMENTOR_VERSION . '#site-editor';
|
||||
}
|
||||
|
||||
if ( self::is_elementor_active() ) {
|
||||
return App::PAGE_ID . '&ver=' . ELEMENTOR_VERSION . '#site-editor/promotion';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function get_theme_builder_url(): string {
|
||||
if ( ! class_exists( 'Elementor\App\App' ) ) {
|
||||
return 'https://go.elementor.com/hello-theme-builder';
|
||||
}
|
||||
|
||||
if ( self::has_pro() ) {
|
||||
return admin_url( 'admin.php?page=' . App::PAGE_ID . '&ver=' . ELEMENTOR_VERSION ) . '#site-editor';
|
||||
}
|
||||
|
||||
if ( self::is_elementor_active() ) {
|
||||
return admin_url( 'admin.php?page=' . App::PAGE_ID . '&ver=' . ELEMENTOR_VERSION ) . '#site-editor/promotion';
|
||||
}
|
||||
|
||||
return 'https://go.elementor.com/hello-theme-builder';
|
||||
}
|
||||
|
||||
public static function get_elementor_activation_link(): string {
|
||||
$plugin = 'elementor/elementor.php';
|
||||
|
||||
$url = 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all';
|
||||
|
||||
return add_query_arg( '_wpnonce', wp_create_nonce( 'activate-plugin_' . $plugin ), $url );
|
||||
}
|
||||
|
||||
public static function get_ai_site_planner_url(): string {
|
||||
return 'https://go.elementor.com/hello-site-planner';
|
||||
}
|
||||
|
||||
public static function get_plugin_install_url( $plugin_slug ): string {
|
||||
$action = 'install-plugin';
|
||||
|
||||
$url = add_query_arg(
|
||||
[
|
||||
'action' => $action,
|
||||
'plugin' => $plugin_slug,
|
||||
'referrer' => 'hello-elementor',
|
||||
],
|
||||
admin_url( 'update.php' )
|
||||
);
|
||||
|
||||
return add_query_arg( '_wpnonce', wp_create_nonce( $action . '_' . $plugin_slug ), $url );
|
||||
}
|
||||
|
||||
public static function get_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';
|
||||
}
|
||||
return $action_link_type;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user