File: /disk001/machen/www/support/wp-content/themes/wp-moose/inc/customizer/sections/frontpage-hero.php
<?php
if ( !function_exists( 'wp_moose_register_hero_options' ) ) {
/**
* Add hero section and controls.
*
* @param WP_Customize_Manager $wp_customize
*/
function wp_moose_register_hero_options( $wp_customize, $section_id, $priority = 100 )
{
$wp_customize->add_section( $section_id, array(
'title' => esc_html__( 'Hero', 'wp-moose' ),
'panel' => 'wp_moose_frontpage_panel',
'priority' => $priority,
) );
$shape_divider_controls = array(
'wp_moose_hero_shape_divider',
'wp_moose_hero_shape_upsell',
'wp_moose_hero_shape_color',
'wp_moose_hero_shape_width',
'wp_moose_hero_shape_height',
'wp_moose_hero_shape_flip',
'wp_moose_hero_shape_invert'
);
$particles_controls = array();
$background_controls = array(
'solid-color' => array_merge( array(
'wp_moose_hero_background_color',
'wp_moose_hero_particles_heading',
'wp_moose_hero_particles_upsell',
'wp_moose_hero_shape_heading'
), $particles_controls, $shape_divider_controls ),
'gradient-color' => array_merge( array(
'wp_moose_hero_background_gradient',
'wp_moose_hero_particles_heading',
'wp_moose_hero_particles_upsell',
'wp_moose_hero_shape_heading'
), $particles_controls, $shape_divider_controls ),
'image' => array_merge( array(
'wp_moose_hero_background_image',
'wp_moose_hero_background_mask',
'wp_moose_hero_particles_heading',
'wp_moose_hero_particles_upsell',
'wp_moose_hero_shape_heading'
), $particles_controls, $shape_divider_controls ),
);
$content_controls = array(
'simple' => array(
'wp_moose_hero_content_upsell',
'wp_moose_hero_content_color',
'wp_moose_hero_content_highlight_color',
'wp_moose_hero_content_alignment',
'wp_moose_hero_title',
'wp_moose_hero_title_highlight',
'wp_moose_hero_subtitle',
'wp_moose_hero_button_primary_text',
'wp_moose_hero_button_primary_url',
'wp_moose_hero_button_secondary_text',
'wp_moose_hero_button_secondary_url',
'wp_moose_hero_button_style'
),
'widgets-area' => array( 'wp_moose_hero_content_upsell', 'wp_moose_go_to_hero_widgets_content' ),
);
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_tabs',
'settings' => array(),
'section' => $section_id,
'custom_control' => Moose_Tabs_Customize_Control::class,
'control_args' => array(
'default_tab' => 'background',
'tabs' => array(
'background' => array(
'label' => esc_html__( 'Background', 'wp-moose' ),
'icon' => 'format-image',
),
'content' => array(
'label' => esc_html__( 'Content', 'wp-moose' ),
'icon' => 'text',
),
),
'controls' => array(
'background' => array(
'wp_moose_hero_background_type' => $background_controls,
),
'content' => array(
'wp_moose_hero_content_type' => $content_controls,
),
),
),
) );
/**
* Background options
*/
// background type
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_background_type',
'label' => esc_html__( 'Background Type', 'wp-moose' ),
'choices' => wp_moose_get_hero_background_types(),
'section' => $section_id,
'custom_control' => Moose_Select_Customize_Control::class,
'control_args' => array(
'subcontrols' => $background_controls,
'should_init' => false,
),
) );
// background color
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_background_color',
'label' => esc_html__( 'Background Color', 'wp-moose' ),
'section' => $section_id,
'custom_control' => WP_Customize_Color_Control::class,
) );
// background gradient
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_background_gradient',
'label' => esc_html__( 'Background Gradient', 'wp-moose' ),
'section' => $section_id,
'custom_control' => Moose_Gradient_Customize_Control::class,
'control_args' => array(),
'settings' => array(
'start' => 'wp_moose_hero_gradient_start',
'end' => 'wp_moose_hero_gradient_end',
'rotation' => 'wp_moose_hero_gradient_rotation',
),
) );
// background image
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_background_image',
'label' => esc_html__( 'Background Image', 'wp-moose' ),
'section' => $section_id,
'custom_control' => WP_Customize_Image_Control::class,
) );
// background mask
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_background_mask',
'label' => esc_html__( 'Background Mask', 'wp-moose' ),
'section' => $section_id,
'custom_control' => Moose_Alpha_Color_Customize_Control::class,
'control_args' => array(
'show_opacity' => true,
),
) );
/**
* background particles
*/
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_particles_heading',
'section' => $section_id,
'settings' => array(),
'custom_control' => Moose_Heading_Customize_Control::class,
'control_args' => array(
'title' => esc_html__( 'PARTICLES', 'wp-moose' ),
'items' => $particles_controls,
'default_state' => 'close',
),
) );
if ( wp_moose_fs()->is_not_paying() ) {
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_particles_upsell',
'section' => $section_id,
'settings' => array(),
'custom_control' => Moose_Info_Customize_Control::class,
'control_args' => array(
'messages' => array( esc_html__( 'Want background particles effect ?', 'wp-moose' ), sprintf( '<a href="%1$s" target="_blank">%2$s</a>', wp_moose_upsell_url(), __( 'Meet Moose Pro', 'wp-moose' ) ), sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://www.wpmoose.com/docs/moose-theme-docs/theme-customization/particles-effect-shape-divider/', __( 'View Video Demo', 'wp-moose' ) ) ),
),
) );
}
/**
* background shape divider
*/
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_shape_heading',
'section' => $section_id,
'settings' => array(),
'custom_control' => Moose_Heading_Customize_Control::class,
'control_args' => array(
'title' => esc_html__( 'SHAPE DIVIDER', 'wp-moose' ),
'items' => $shape_divider_controls,
'default_state' => 'close',
),
) );
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_shape_divider',
'label' => esc_html__( 'Shape Divider', 'wp-moose' ),
'section' => $section_id,
'choices' => wp_moose_array_pluck( 'title', wp_moose_get_shapes() ),
'custom_control' => Moose_Select_Customize_Control::class,
'control_args' => array(
'subcontrols' => wp_moose_array_pluck( 'options', wp_moose_get_shapes() ),
'should_init' => false,
),
) );
if ( wp_moose_fs()->is_not_paying() ) {
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_shape_upsell',
'section' => $section_id,
'settings' => array(),
'custom_control' => Moose_Info_Customize_Control::class,
'control_args' => array(
'messages' => array( esc_html__( 'Want unlock more Shape Dividers ?', 'wp-moose' ), sprintf( '<a href="%1$s" target="_blank">%2$s</a>', wp_moose_upsell_url(), __( 'Meet Moose Pro', 'wp-moose' ) ), sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://www.wpmoose.com/docs/moose-theme-docs/theme-customization/particles-effect-shape-divider/', __( 'Shape Divider Video Tutorial', 'wp-moose' ) ) ),
),
) );
}
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_shape_color',
'label' => esc_html__( 'Shape Color', 'wp-moose' ),
'section' => $section_id,
'custom_control' => WP_Customize_Color_Control::class,
) );
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_shape_width',
'label' => esc_html__( 'Width', 'wp-moose' ),
'section' => $section_id,
'custom_control' => Moose_Slider_Customize_Control::class,
'settings' => array(
'desktop' => 'wp_moose_hero_shape_width',
),
'choices' => array(
'desktop' => array(
'min' => 100,
'max' => 500,
'step' => 1,
'unit' => '%',
),
),
) );
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_shape_height',
'label' => esc_html__( 'Height', 'wp-moose' ),
'section' => $section_id,
'custom_control' => Moose_Slider_Customize_Control::class,
'settings' => array(
'desktop' => 'wp_moose_hero_shape_height',
),
'choices' => array(
'desktop' => array(
'min' => 0,
'max' => 200,
'step' => 1,
'unit' => 'px',
),
),
) );
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_shape_flip',
'label' => esc_html__( 'Flip', 'wp-moose' ),
'section' => $section_id,
'custom_control' => Moose_Switch_Customize_Control::class,
) );
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_shape_invert',
'label' => esc_html__( 'Invert', 'wp-moose' ),
'section' => $section_id,
'custom_control' => Moose_Switch_Customize_Control::class,
) );
/**
* Content options
*/
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_content_type',
'label' => esc_html__( 'Content Type', 'wp-moose' ),
'choices' => wp_moose_get_hero_content_type(),
'section' => $section_id,
'custom_control' => Moose_Select_Customize_Control::class,
'control_args' => array(
'subcontrols' => $content_controls,
'should_init' => false,
),
) );
if ( wp_moose_fs()->is_not_paying() ) {
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_content_upsell',
'section' => $section_id,
'settings' => array(),
'custom_control' => Moose_Info_Customize_Control::class,
'control_args' => array(
'messages' => array(
esc_html__( 'In our pro version, you can:', 'wp-moose' ),
esc_html__( 'Fully customize your hero content using widgets.', 'wp-moose' ),
esc_html__( 'Customize title highlight color.', 'wp-moose' ),
sprintf( '<a href="%1$s" target="_blank">%2$s</a>', wp_moose_upsell_url(), __( 'Meet Moose Pro', 'wp-moose' ) ),
sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://www.wpmoose.com/docs/moose-theme-docs/theme-customization/change-hero-content-widget/', __( 'View Video Demo', 'wp-moose' ) )
),
),
) );
}
// content color
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_content_color',
'label' => esc_html__( 'Content Color', 'wp-moose' ),
'section' => $section_id,
'custom_control' => WP_Customize_Color_Control::class,
) );
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_content_alignment',
'label' => esc_html__( 'Alignment', 'wp-moose' ),
'type' => 'select',
'section' => $section_id,
'choices' => wp_moose_get_text_align_options(),
) );
$simple_content_settings = array(
'wp_moose_hero_title' => esc_html__( 'Title', 'wp-moose' ),
'wp_moose_hero_title_highlight' => esc_html__( 'Highlight', 'wp-moose' ),
'wp_moose_hero_subtitle' => esc_html__( 'Subtitle', 'wp-moose' ),
'wp_moose_hero_button_primary_text' => esc_html__( 'Primary Button Text', 'wp-moose' ),
'wp_moose_hero_button_primary_url' => esc_html__( 'Primary Button URL', 'wp-moose' ),
'wp_moose_hero_button_secondary_text' => esc_html__( 'Secondary Button Text', 'wp-moose' ),
'wp_moose_hero_button_secondary_url' => esc_html__( 'Secondary Button URL', 'wp-moose' ),
);
foreach ( $simple_content_settings as $id => $label ) {
wp_moose_register_options( $wp_customize, array(
'name' => $id,
'label' => $label,
'section' => $section_id,
'type' => 'text',
) );
}
wp_moose_register_options( $wp_customize, array(
'name' => 'wp_moose_hero_button_style',
'label' => esc_html__( 'Button Style', 'wp-moose' ),
'type' => 'select',
'section' => $section_id,
'choices' => wp_moose_get_button_style_options(),
) );
}
}
if ( !function_exists( 'get_wp_moose_hero_content_style' ) ) {
function get_wp_moose_hero_content_style()
{
$color = get_wp_moose_option( 'wp_moose_hero_content_color' );
return "color: {$color}";
}
}
if ( !function_exists( 'get_wp_moose_hero_button_style' ) ) {
/**
* Return css class for button in the hero section
*
* @return string
*/
function get_wp_moose_hero_button_style()
{
return wp_moose_get_button_style_css( get_wp_moose_option( 'wp_moose_hero_button_style' ) );
}
}
if ( !function_exists( 'get_wp_moose_hero_background_style' ) ) {
/**
* Return inline styles for the background in the hero section
*
* @return string
*/
function get_wp_moose_hero_background_style()
{
$type = get_wp_moose_option( 'wp_moose_hero_background_type' );
switch ( $type ) {
case 'solid-color':
$color = get_wp_moose_option( 'wp_moose_hero_background_color' );
return "background-color: {$color}";
case 'gradient-color':
$rotation = get_wp_moose_option( 'wp_moose_hero_gradient_rotation' );
$start = get_wp_moose_option( 'wp_moose_hero_gradient_start' );
$end = get_wp_moose_option( 'wp_moose_hero_gradient_end' );
return "background-image: linear-gradient({$rotation}deg, {$start} 0%, {$end} 100%)";
case 'image':
$image = get_wp_moose_option( 'wp_moose_hero_background_image' );
return "background-image: url({$image})";
}
return '';
}
}
if ( !function_exists( 'get_wp_moose_hero_mask_style' ) ) {
/**
* Return inline styles for the mask in the hero section
*
* @return string
*/
function get_wp_moose_hero_mask_style()
{
$type = get_wp_moose_option( 'wp_moose_hero_background_type' );
if ( $type !== 'image' ) {
return 'display: none';
}
return 'background-color: ' . get_wp_moose_option( 'wp_moose_hero_background_mask' );
}
}