MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /disk001/machen/public_html/support/wp-content/themes/wp-moose/inc/customizer/helpers.php
<?php

/**
 * Load necessary Customizer controls and functions.
 *
 * @package Moose
 */

if ( !defined( 'ABSPATH' ) ) {
    exit;
    // Exit if accessed directly.
}

/**
 * Controls
 */
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-customize-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-image-radio-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-gradient-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-select-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-slider-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-tabs-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-alpha-color-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-call-to-action-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-sortable-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-switch-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-info-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-heading-control.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-divider-control.php';
/**
 * Functions
 */
if ( !function_exists( 'wp_moose_register_options' ) ) {
    /**
     * Function to register control and setting.
     *
     * @param $wp_customize
     * @param $arg
     *
     * @since 1.0.0
     */
    function wp_moose_register_options( $wp_customize, $arg )
    {
        // Initialize Settings
        $settings = array();
        
        if ( isset( $arg['setting'] ) ) {
            $arg['settings'] = array( $arg['setting'] );
            
            if ( is_array( $arg['setting'] ) && isset( $arg['setting']['id'] ) ) {
                $settings = $arg['setting']['id'];
            } else {
                $settings = $arg['name'];
            }
        
        }
        
        
        if ( !isset( $arg['settings'] ) ) {
            $arg['settings'] = array( $arg['name'] );
            $settings = $arg['name'];
        }
        
        foreach ( $arg['settings'] as $key => $options ) {
            $options = ( is_array( $options ) ? $options : get_wp_moose_option_args( $options ) );
            $id = ( isset( $options['id'] ) ? $options['id'] : $arg['name'] );
            if ( is_array( $settings ) ) {
                $settings[$key] = $id;
            }
            $wp_customize->add_setting( $id, array(
                'type'               => 'theme_mod',
                'sanitize_callback'  => $options['sanitize_callback'],
                'default'            => ( isset( $options['default'] ) ? $options['default'] : '' ),
                'transport'          => ( isset( $options['transport'] ) ? $options['transport'] : 'refresh' ),
                'theme_supports'     => ( isset( $options['theme_supports'] ) ? $options['theme_supports'] : '' ),
                'description_hidden' => ( isset( $options['description_hidden'] ) ? $options['description_hidden'] : 0 ),
            ) );
        }
        // Initialize control args.
        $control = array(
            'label'    => ( isset( $arg['label'] ) ? $arg['label'] : '' ),
            'section'  => $arg['section'],
            'settings' => $settings,
        );
        if ( isset( $arg['control_args'] ) ) {
            $control = array_merge( $control, $arg['control_args'] );
        }
        if ( isset( $arg['active_callback'] ) ) {
            $control['active_callback'] = $arg['active_callback'];
        }
        if ( isset( $arg['priority'] ) ) {
            $control['priority'] = $arg['priority'];
        }
        if ( isset( $arg['choices'] ) ) {
            $control['choices'] = $arg['choices'];
        }
        if ( isset( $arg['type'] ) ) {
            $control['type'] = $arg['type'];
        }
        if ( isset( $arg['input_attrs'] ) ) {
            $control['input_attrs'] = $arg['input_attrs'];
        }
        if ( isset( $arg['description'] ) ) {
            $control['description'] = $arg['description'];
        }
        // Add control
        
        if ( isset( $arg['custom_control'] ) ) {
            $wp_customize->add_control( new $arg['custom_control']( $wp_customize, $arg['name'], $control ) );
        } else {
            $wp_customize->add_control( $arg['name'], $control );
        }
    
    }

}
if ( !function_exists( 'wp_moose_change_customizer_object' ) ) {
    /**
     * Change a customizer object.
     *
     * @param $wp_customize
     * @param $type
     * @param $id
     * @param $property
     * @param $value
     *
     * @since 1.0.0
     */
    function wp_moose_change_customizer_object(
        $wp_customize,
        $type,
        $id,
        $property,
        $value
    )
    {
        $accepted_types = array(
            'setting',
            'control',
            'section',
            'panel'
        );
        if ( !in_array( $type, $accepted_types, true ) ) {
            return;
        }
        $object = call_user_func_array( array( $wp_customize, 'get_' . $type ), array( $id ) );
        if ( empty($object) ) {
            return;
        }
        $object->{$property} = $value;
    }

}
if ( !function_exists( 'wp_moose_upsell_url' ) ) {
    /**
     * @return string
     */
    function wp_moose_upsell_url()
    {
        return 'https://www.wpmoose.com/themes/wp-moose-theme/?ref=customizer-panel';
        // return network_admin_url( 'admin.php?page=wp-moose-theme-pricing' );
    }

}
if ( !function_exists( 'wp_moose_go_to_upsell' ) ) {
    /**
     * Go to upsell
     */
    function wp_moose_go_to_upsell(
        $wp_customize,
        $section,
        $id,
        $label
    )
    {
        if ( wp_moose_fs()->is_not_paying() ) {
            wp_moose_register_options( $wp_customize, array(
                'name'           => $id,
                'settings'       => array(),
                'section'        => $section,
                'custom_control' => Moose_Call_To_Action_Customize_Control::class,
                'control_args'   => array(
                'action_label'  => $label,
                'action_type'   => 'url',
                'action_target' => wp_moose_upsell_url(),
            ),
            ) );
        }
    }

}