<?php
/* Add Theme Options Panel Tabs Code Here*/
/* Add Hook For Add Extra Theme Options */
add_action("epanel_render_maintabs", 'px_epanel_tabs');
function px_epanel_tabs()
{
	px_epanel_fields();  ?>
<li>
    <div class="px-menu-options-tab">
        <a href="#wrap-px" >
            <div class="wp-menu-image dashicons-before" aria-hidden="true">
            <img src="<?php echo esc_url(PX_COMPANY_LOGO); ?>" alt="<?php echo esc_html(PX_THEMENAME); ?>"
                class="wp-menu-image dashicons-before dashicons-admin-generic px_panel_tab_img" style="margin-right:5px;padding: 5px;">
            </div>
            <div class="wp-menu-name">
                <?php echo esc_attr(PX_THEMENAME.' Options' ,'px'); ?>
            </div>
        </a>
    </div>
</li>
<?php
}

/* Add Hook For  Add Extra Theme Tabs Options */
add_action("et_epanel_changing_options", 'px_epanel_fields');
function px_epanel_fields()
{
    global $epanelMainTabs, $themename, $shortname, $options ;
	$themename = 'px';
    $options[] = array(
        "name" => "wrap-px",
        "type" => "contenttab-wrapstart",);

            $options[] = array(
            "type" => "subnavtab-start",);
                
				$options[] = array(
                    "name" => "px-2",
                    "type" => "subnav-tab",
                    "desc" => esc_html__("Theme Color", $themename)
                );
                $options[] = array(
                    "name" => "px-3",
                    "type" => "subnav-tab",
                    "desc" => esc_html__("Preloader", $themename)
                );
				$options[] = array(
                    "name" => "px-4",
                    "type" => "subnav-tab",
                    "desc" => esc_html__("Mobile Menu", $themename)
                );
				$options[] = array(
                    "name" => "px-5",
                    "type" => "subnav-tab",
                    "desc" => esc_html__("Back To Top", $themename)
                );

                $options[] = array(
                    "name" => "px-6",
                    "type" => "subnav-tab",
                    "desc" => esc_html__("Custom Cursor", $themename)
                );

                $options[] = array(
                "type" => "subnavtab-end",);
				
				//**************************General Options Start Here******************************************//

				
				//**************************General Options End Here******************************************//
                $options[] = array(
                "name" => "px-2",
                "type" => "subcontent-start",);	

                    $options[] = array(
                        'name' => esc_html__('Color Picker Settings', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'PX_theme_color_picker_notice',

                    ); 
                    $options[] = array(
                        "name" =>esc_html__('Front Color Picker Options', $themename),
                        "id" => $shortname . "_PX_show_color_option",
                        "type" => "checkbox2",
                        "std" => "off",
                        "desc" =>esc_html__("Enable / Disable color picker for front site .", $themename),
                    );

                    $options[] = array(
                        'name' => esc_html__('Theme Color Options', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'PX_theme_color_notice',
                    ); 

                    $options[] = array( "name"         => esc_html__("Primary Color", $themename),
                        "id"           => $shortname . "_PX_color_palette_01",
                        "type"         => "et_color_palette",
                        "items_amount" => 1,
                        "std"          => '#2ea3f2',
                        "desc"         => esc_html__("Define the default color palette for color pickers in the Divi Builder.", $themename),
                    );

                    $options[] = array( "name"         => esc_html__("Secondary Color", $themename),
                        "id"           => $shortname . "_PX_color_palette_02",
                        "type"         => "et_color_palette",
                        "items_amount" => 1,
                        "std"          => '#2ea3f2',
                        "desc"         => esc_html__("Define the default secondary color palette for color pickers in the Divi Builder.", $themename),
                    );

                $options[] = array(
                "name" => "px-2",
                "type" => "subcontent-end",);



            //**************************Pre-Loader Options Start Here******************************************//

                $options[] = array(
                "name" => "px-3",
                "type" => "subcontent-start",);

                    $options[] = array(
                        'name' => esc_html__('General', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
                    $options[] = array(
                        'name' => esc_html__('Display Preloader On Site', $themename),
                        'id' => $shortname . "_PX_pre_preloader",
                        'std' => 'off',
                        "type" => "checkbox",
                        'desc' => esc_html__("Enable or Disable the site preloader. Turn this off if you do not want to display a preloader on your website.", $themename),
                    );
                    $options[] = array(
                        'name' => esc_html__('', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
					 $options[] = array(
                        'name' => esc_html__('Preloader Text Settings', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                        'desc' => esc_html__("Enable this option to display custom text below the preloader on your site. Disable it to hide the text.", $themename),
                   );
					 $options[] = array(
                        'name' => esc_html__('', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
					 $options[] = array(
                        'name' => esc_html__('Display Text Below Preloader On Site', $themename),
                        'id' => $shortname . "_PX_pre_display_text_preloader",
                        'std' => 'off',
                        "type" => "checkbox",
                        'desc' => esc_html__("Enable Or Disbale this option to display custom text below the preloader on your site. Disable it to hide the text.", $themename),
                    );
					$options[] = array(
                        'name' => esc_html__('Preloader Text', $themename),
                        'id' => $shortname . "_PX_pre_text_preloader",
                        'std' => 'Divi Child Theme',
                        'type' => 'text',
                        'desc' => esc_html__("Use this option to add custom text that will appear below the preloader on your website.", $themename),

                    );
					
					 $options[] = array(
                        'name' => esc_html__('Gradient Text Color 1', $themename),
                        'id' => $shortname . "_PX_pre_text_color1",
                        'std' => '#2ea3f2',
                        "type" => "et_color_palette",
                        'desc' =>  esc_html__("Select the first color for the gradient text effect.", $themename),

                    );
					
					 $options[] = array(
                        'name' => esc_html__('Gradient Text Color 2', $themename),
                        'id' => $shortname . "_PX_pre_text_color2",
                        'std' => '#2ea3f2',
                        "type" => "et_color_palette",
                        'desc' => esc_html__("Select the second color for the gradient text effect.", $themename),
                    );
					
					
                    $options[] = array(
                        'name' => esc_html__('Preloader Image Settings', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
                    $options[] = array(
                        'name' => esc_html__('Preloader Images', $themename),
                        "type" => "callback_function",
                        "function_name" => 'px_list_preloader_images',
                        'desc' => esc_html__("Configure the image displayed in the preloader on your site.", $themename),
                    );
                    $options[] = array(
                        'name' => esc_html__('Preloader Custom Image Uploader(GIF)', $themename),
                        'id' => $shortname . "_PX_pre_custom_preloader",
                        'std' => '',
                        "type" => "upload",
                        'desc' => esc_html__("Upload an image to display in the preloader while your site is loading.", $themename),
                    );
                    $options[] = array(
                        'name' => esc_html__('Custom Preloader Image Width Size', $themename),
                        'id' => $shortname . "_PX_pre_image_width_preloader",
                        'std' => '50',
                        'type' => 'text',
                        'desc' => esc_html__("Adjust the width of the custom preloader image displayed on your site.", $themename),
                    );
                    $options[] = array(
                        'name' => esc_html__('Custom Preloader Image Height Size', $themename),
                        'id' => $shortname . "_PX_pre_image_height_preloader",
                        'std' => '50',
                        'type' => 'text',
                        'desc' => esc_html__("Adjust the Height of the custom preloader image displayed on your site.", $themename),
                    );
                    $options[] = array(
                        'name' => esc_html__('', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
                    $options[] = array(
                        'name' => esc_html__('Color Settings', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                        'desc' => esc_html__("Adjust settings the preloader colors to align with your brand identity.", $themename),
                    );
                    $options[] = array(
                        'name' => esc_html__('Preloader Color', $themename),
                        'id' => $shortname . "_PX_pre_preloader_color",
                        'std' => '#2ea3f2',
                        "type" => "et_color_palette",
                        'desc' => esc_html__("Customize preloader colors to match your brand.", $themename),
                    );
                    $options[] = array(
                        'name' => esc_html__('Background Color', $themename),
                        'id' => $shortname . "_PX_pre_background_color",
                        'std' => '#ffffff',
                        "type" => "et_color_palette",
                        'desc' => esc_html__("Customize preloader background colors to match your brand.", $themename),
                    );
                    $options[] = array(
                        'name' => esc_html__('', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
                    $options[] = array(
                        'name' => esc_html__('Animation Settings', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
                    $options[] = array(
                        'name' => esc_html__('Preloader Effects', $themename),
                        'id' => $shortname . "_PX_pre_effects",
                        'std' => 'fadeOut',
                        "type" => "select",
                        "options" => array(
                        'fadeOut' => esc_html__('FadeOut ', $themename),
                        'slideUp' => esc_html__('SlideUp', $themename)
						
                        ),
                        'et_save_values' => true,
                        'desc' => '',
                    );
                    $options[] = array(
                        'name' => esc_html__('Preloader Fadeout Speed', $themename),
                        'id' => $shortname . "_PX_pre_fadeout_speed",
                        'std' => 'fast',
                        "type" => "select",
                        "options" => array(
                        'fast' => esc_html__('Fast', $themename),
                        'slow' => esc_html__('Slow', $themename),
                        ),
                        'et_save_values' => true,
                        'desc' => '',
                    );
                    $options[] = array(
                        'name' => esc_html__('Preloader Delay Time', $themename),
                        'type' => 'text',
                        'id' => $shortname . "_PX_pre_delay_time",
                        'std' => '350',
                        'desc' => '',
                    );
                    $options[] = array(
                        'name' => esc_html__('Preloader Body Opacity', $themename),
                        'type' => 'text',
                        'id' => $shortname . "_PX_pre_body_opacity",
                        'std' => '1',
                        'desc' => '',
                    );


                $options[] = array(
                "name" => "px-3",
                "type" => "subcontent-end",);

            //**************************Pre-Loader Options End Here******************************************//

			//**************************Mobile Menu Start Here******************************************//

                $options[] = array(
                "name" => "px-4",
                "type" => "subcontent-start",);
					 $options[] = array(
                        'name' => esc_html__('Mobile Menu Settings', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
					
                    $options[] = array(
                        "name" =>esc_html__('Mobile Menu Options', $themename),
                        "id" => $shortname . "_PX_Mobile_Menu_option",
                        "type" => "checkbox2",
                        "std" => "on",
                        "desc" =>esc_html__("Enable / Disable Custom Mobile Menu in the Divi Builder.", $themename),
                    );
					$options[] = array(
                        'name' => esc_html__('Mobile Menu Style', $themename),
                        "type" => "callback_function",
                        "function_name" => 'px_list_menu_images',
                        'desc' => '',
                    );
					$options[] = array(
                        'name' => esc_html__('', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
					$options[] = array(
                        'name' => esc_html__('Hamburger Menu Settings', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
					 $options[] = array(
                        "name" =>esc_html__('Hamburger Menu Options', $themename),
                        "id" => $shortname . "_PX_hamburger_menu_option",
                        "type" => "checkbox2",
                        "std" => "off",
                        "desc" =>esc_html__("Enable / Disable Custom Hamburger Menu in the Divi Builder.", $themename),
                    );
                    
                    $options[] = array(
                        'name' => esc_html__('Hamburger Menu Styles', $themename),
                        "type" => "callback_function",
                        "function_name" => 'px_list_hamburger_menu',
                        'desc' => '',
                    );
                    $options[] = array(
                        'name' => esc_html__('Hamburger Menu Icon Color', $themename),
                        'type' => 'et_color_palette',
                        'id' => $shortname . "_px_hamburger_menu_color",
                        'desc' => esc_html__('Hamburger Menu Icon Color', $themename),
                        'std' => '#2ea3f2',
                    );
                    $options[] = array(
                        'name' => esc_html__('Hamburger Menu Active Icon Color', $themename),
                        'type' => 'et_color_palette',
                        'id' => $shortname . "_px_hamburger_menu_active_color",
                        'desc' => esc_html__('Hamburger Menu Active Icon Color', $themename),
                        'std' => '#2ea3f2',
                    );

					$options[] = array(
                        'name' => esc_html__('', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'px_blank',
                    );
					$options[] = array(
                        'name' => esc_html__('Mobile Bar Header Color Settings', $themename),
                        'desc' => '',
                        "type" => "callback_function",
                        "function_name" => 'PX_Mobile_Header_Notice',
                    );
					 $options[] = array(
                        "name" =>esc_html__('Mobile Bar Header Color Option', $themename),
                        "id" => $shortname . "_px_mobilebar_menu_option",
                        "type" => "checkbox2",
                        "std" => "off",
                        "desc" =>esc_html__("Enable / Disable Custom Mobile Bar Header Color in the Divi Builder.", $themename),
                    );
					 $options[] = array(
                        'name' => esc_html__('Mobile Bar Header Color', $themename),
                        'type' => 'et_color_palette',
                        'id' => $shortname . "_px_mobilebar_menu_option_color",
                        'desc' => esc_html__('Hamburger Menu Icon Color', $themename),
                        'std' => '#2ea3f2',
                    );
	
				$options[] = array(

                "name" => "px-4",
                "type" => "subcontent-end",);
				
			//**************************Mobile Menu End Here******************************************//


			//**************************Back To Top Start Here******************************************//

                $options[] = array(
                    "name" => "px-5",
                    "type" => "subcontent-start",
                );

                $options[] = array(
                    'name' => esc_html__('General Back To Top Settings', $themename),
                    "type" => "callback_function",
                    "function_name" => 'PX_btt',
                );

                $options[] = array(
                    'name' => esc_html__('Back To Top Background Color', $themename),
                    'id' => $shortname . "_PX__btt_bg_color",
                    'std' => '#2ea3f2',
                    "type" => "et_color_palette",
                );

                $options[] = array(
                    'name' => esc_html__('Back To Top Icon Color', $themename),
                    'id' => $shortname . "_PX__btt_icon_color",
                    'std' => '#ffffff',
                    "type" => "et_color_palette",
                );

                $options[] = array(
                    'name' => esc_html__('Predefined Back To Top Style', $themename),
                    "type" => "callback_function",
                    "function_name" => function_exists('px_list_backtotop_styles') ? 'px_list_backtotop_styles' : 'px_blank',
                );

                $options[] = array(
                    'name' => esc_html__('Custom Back To Top Settings', $themename),
                    "type" => "callback_function",
                    "function_name" => 'PX_custom_btt',
                );


                $options[] = array(
                    'name' => esc_html__('Enable Custom Back To Top On Your Site', $themename),
                    'id' => $shortname . "_PX__btt_custom_enable",
                    'std' => 'off',
                    "type" => "checkbox",
                );

                $options[] = array(
                    'name' => esc_html__('Upload Your Icon Image (PNG/JPG)', $themename),
                    'id'   => $shortname . "_PX__btt_icon",
                    'type' => 'upload',
                );

                $options[] = array(
                    'name' => esc_html__('Image Width', $themename),
                    'id' => $shortname . "_PX__btt_img_width",
                    'std' => '50',
                    'type' => 'text',
                );

                $options[] = array(
                    'name' => esc_html__('Image Height', $themename),
                    'id' => $shortname . "_PX__btt_img_height",
                    'std' => '50',
                    'type' => 'text',
                );
                $options[] = array(
                    'name' => esc_html__('Button Size (Px)', $themename),
                    'id'   => $shortname . "_PX__btt_size",
                    'std'  => '70',
                    'type' => 'text',
                );

                $options[] = array(
                    'name' => esc_html__('Icon Size (Px)', $themename),
                    'id'   => $shortname . "_PX__btt_icon_size",
                    'std'  => '22',
                    'type' => 'text',
                );

                $options[] = array(
                    'name' => esc_html__('Progress Color', $themename),
                    'id'   => $shortname . "_PX__btt_progress",
                    'std'  => '#2ea3f2',
                    'type' => 'et_color_palette',
                );
                
                $options[] = array(
                    'name' => esc_html__('Border Rounded (Px)', $themename),
                    'id'   => $shortname . "_PX__btt_radius",
                    'std'  => '12',
                    'type' => 'text',
                );

                $options[] = array(
                    'name' => esc_html__('Scroll Speed (Ms)', $themename),
                    'id'   => $shortname . "_PX__btt_speed",
                    'std'  => '800',
                    'type' => 'text',
                );

                $options[] = array(
                    "name" => "px-5",
                    "type" => "subcontent-end",
                );
                      

				//**************************Back To Top End Here******************************************//


                //**************************Custom Cursor Options Start Here ******************************************//


                    $options[] = array(
                        "name" => "px-6",
                        "type" => "subcontent-start",
                    );

                    $options[] = array(
                        'name' => esc_html__('Custom Cursor Settings', $themename),
                        "type" => "callback_function",
                        "function_name" => 'PX_cursor_info',
                    );

                    $options[] = array(
                        'name' => esc_html__('Use Custom Cursor In Your Site !', $themename),
                        'id' => $shortname . "_PX_cursor_enable",
                        'std' => 'off',
                        "type" => "checkbox",
                    );

                    $options[] = array(
                        'name'          => esc_html__('Cursor Style', $themename),
                        'id'            => 'divi_cursor_images', 
                        'type'          => 'callback_function',
                        'function_name' => 'px_list_cursor_styles',
                    );

                    $options[] = array(
                        'name' => esc_html__('Cursor Background Color', $themename),
                        'id'   => $shortname . "_PX_cursor_bg",
                        'std'  => '#000000',
                        "type" => "et_color_palette",
                    );

                    $options[] = array(
                        'name' => esc_html__('Cursor Border Color', $themename),
                        'id'   => $shortname . "_PX_cursor_border",
                        'std'  => '#ffffff',
                        "type" => "et_color_palette",
                    );

                    $options[] = array(
                        'name' => esc_html__('Cursor Size (Px)', $themename),
                        'id'   => $shortname . "_PX_cursor_size",
                        'std'  => '20',
                        'type' => 'text',
                    );

                    $options[] = array(
                        "name" => "px-6",
                        "type" => "subcontent-end",
                    );


                    if (!function_exists('PX_cursor_info')) {
                        function PX_cursor_info() {
                            $px_allowedhtml = PX_allowed_html();
                            echo wp_kses(
                                '<div class="px-custom-notice">
                                    <p class="px-custom-notice-text">
                                        <b>Custom Cursor Styles</b><br>
                                        Note: Customize your website cursor using our predefined styles to replace the default cursor on the front end.
                                    </p>
                                </div>',
                                $px_allowedhtml
                            );
                        }
                    }
				//**************************ustom Cursor Options End Here******************************************//

                $options[] = array(
                    "name" => "wrap-px",
                    "type" => "contenttab-wrapend",);
                }

                /** End Theme Options Panel Tabs Options Code Here **/
                function PX_theme_color_picker_notice(){
                    $px_allowedhtml = PX_allowed_html();

                    echo wp_kses(
                        '<div class="px-custom-notice">
                            <p class="px-custom-notice-text">
                                <b>Enable or Disable the front-end color picker using the option below. </b><br>
                                Note: This allows users to view only the theme colors on the front end.
                            </p>
                        </div>',
                        $px_allowedhtml
                    );
                }

                function PX_theme_color_notice(){
                    $px_allowedhtml = PX_allowed_html();

                    echo wp_kses(
                        '<div class="px-custom-notice">
                            <p class="px-custom-notice-text">
                                <b>Theme Color Options Deprecated for Divi 5</b><br>
                                Note: This option is only available for existing DCT Theme users who are upgrading and want to retain their old primary and secondary color settings.
                            </p>
                        </div>',
                        $px_allowedhtml
                    );
                }
                if (!function_exists('px_blank')) {
                    function px_blank() {}
                }

                if (!function_exists('px_list_Back_To_Top_images')) {
                    function px_list_Back_To_Top_images() {
                        echo '<div></div>';
                    }
                }

                if (!function_exists('px_list_backtotop_styles')) {
                    function px_list_backtotop_styles() {
                        echo '<div></div>';
                    }
                }
                /*Mobile Bar Header Color Option Notice*/
                function PX_Mobile_Header_Notice(){
                    $px_allowedhtml = PX_allowed_html();

                    echo wp_kses(
                        '<div class="px-custom-notice">
                            <p class="px-custom-notice-text">
                                <b>Mobile Browser Theme Color</b><br>
                                Customize the browser address bar color on supported mobile browsers like Chrome on Android for a more integrated appearance.<br>
                                <small><strong>Note:</strong> Limited support on iPhone Safari and may not work in standard browser tabs.</small>
                            </p>
                        </div>',
                        $px_allowedhtml
                    );
                } 
                function PX_btt(){
                    $px_allowedhtml = PX_allowed_html();

                    echo wp_kses(
                        '<div class="px-custom-notice">
                            <p class="px-custom-notice-text">
                                <b>To enable/disable Back to top go to Divi Theme Options -> General -> General</b><br>
                                And find "Back To Top Button" Option. Click here <a href="'.admin_url("/admin.php?page=et_divi_options#wrap-general").'"  target="_blank">Back To Top Button Option</a>
                            </p>
                        </div>',
                        $px_allowedhtml
                    );
                }                                
                function PX_custom_btt() {
                    $px_allowedhtml = PX_allowed_html();
                    echo wp_kses('<p class="px-custom-notice-text">Advanced settings for the custom scroll Back to top progress button.</p>',
                        $px_allowedhtml
                    );
                }    
        function px_blank(){echo '';}
        /*---------Mobile Menu---------------*/
        function px_list_menu_images(){
                $pxpre_menu_images = array(
                'm_style1' => array(
                    'value' => 'm_style1',
                    'img' => get_stylesheet_directory_uri(). '/assets/img/menu/m_style1.png' 
                ),
                'm_style2' => array(
                    'value' => 'm_style2',
                    'img' => get_stylesheet_directory_uri(). '/assets/img/menu/m_style2.png'
                ),
                'm_style3' => array(
                    'value' => 'm_style3',
                    'img' => get_stylesheet_directory_uri(). '/assets/img/menu/m_style3.png'
                ),
                'm_style4' => array(
                    'value' => 'm_style4',
                    'img' => get_stylesheet_directory_uri(). '/assets/img/menu/m_style4.png'
                )
            );
            $divi_px_menu_images = get_option( 'divi_px_menu_images' ) ;
            if ( $divi_px_menu_images != '' ){ 
                $divi_px_menu_images = get_option( 'divi_px_menu_images' ) ;
            }else{
                $divi_px_menu_images = 'm_style1' ;
            }
            foreach( $pxpre_menu_images as $images ) : ?>
                <div class="p_loader_div p_mobile_menu">
                    <input type="radio" name="divi_px_menu_images" value="<?php esc_attr_e( $images['value'] ); ?>" <?php checked(
                        esc_attr($divi_px_menu_images), $images['value'] ); ?> class="p_loader_select"/>
                    <label for="<?php echo esc_attr($images['value']); ?>"><img class="px_menu_images"
                            src="<?php echo esc_url( $images['img'] ); ?>" width="70" alt="<?php echo esc_attr($images['value']); ?>" />
                    </label>
                </div>
                <?php endforeach;
        }


/*---------Preloader---------------*/
function px_list_preloader_images(){
		$pxpre_preloader_images = array(
		'px_loader1' => array(
			'value' => 'px_loader1',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-1.gif' 
		),
		'px_loader2' => array(
			'value' => 'px_loader2',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-2.gif'
		),
		'px_loader3' => array(
			'value' => 'px_loader3',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-3.gif'
		),
		'px_loader4' => array(
			'value' => 'px_loader4',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-4.gif'
		),
		'px_loader5' => array(
			'value' => 'px_loader5',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-5.gif'
		),
		'px_loader6' => array(
			'value' => 'px_loader6',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-6.gif'
		),
		'px_loader7' => array(
			'value' => 'px_loader7',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-7.gif'
		),
		'px_loader8' => array(
			'value' => 'px_loader8',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-8.gif'
		),
		'px_loader9' => array(
			'value' => 'px_loader9',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-9.gif'
		),
		'px_loader10' => array(
			'value' => 'px_loader10',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-10.gif'
		),
		'px_loader11' => array(
			'value' => 'px_loader11',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-11.gif'
		),
		'px_loader12' => array(
			'value' => 'px_loader12',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-12.gif'
		),
		'px_loader13' => array(
			'value' => 'px_loader13',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-13.gif'
		),
		'px_loader14' => array(
			'value' => 'px_loader14',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-14.gif'
		),
		'px_loader15' => array(
			'value' => 'px_loader15',
			'img' => get_stylesheet_directory_uri(). '/assets/img/preloader/px-loader-15.gif'
		)
	);
	$divi_pxpre_preloader_images = get_option( 'divi_pxpre_preloader_images' ) ;
	if ( $divi_pxpre_preloader_images != '' ){ 
		$divi_pxpre_preloader_images = get_option( 'divi_pxpre_preloader_images' ) ;
	}else{
		$divi_pxpre_preloader_images = 'px_loader1' ;
	}
	 foreach( $pxpre_preloader_images as $images ) : ?>
<div class="p_loader_div">
    <input type="radio" name="divi_pxpre_preloader_images" value="<?php esc_attr_e( $images['value'] ); ?>" <?php
        checked( esc_attr($divi_pxpre_preloader_images), $images['value'] ); ?> class="p_loader_select"/>
    <label for="<?php echo esc_attr($images['value']); ?>"><img src="<?php echo esc_url( $images['img'] ); ?>"
            width="70" alt="<?php echo esc_attr($images['value']); ?>" /> </label>
</div>
<?php endforeach;
}



/* Adding Preloader Options Code Here **/
/*---------Body Class---------------*/
function px_body_class( $classes ) {


	if ( 'on' === et_get_option( 'divi_PX_hamburger_menu_option', 'on' ) ){
		
		/*---------Hemburger Menu---------------*/
		$divi_px_list_hamburger_menu = get_option( 'divi_px_list_hamburger_menu' ) ;
		if ( $divi_px_list_hamburger_menu != '' ){ 
			$divi_px_list_hamburger_menu = get_option( 'divi_px_list_hamburger_menu' ) ;
		}else{
			$divi_px_list_hamburger_menu = 'px_hamburgermenu-1' ;
		}
		$classes[] = 'px_hamburger_menu style-'.$divi_px_list_hamburger_menu;
	}

	if ( 'on' === et_get_option( 'divi_PX_Mobile_Menu_option', 'on' ) ){	
		/*---------Mobile Menu---------------*/
		
		 $divi_mobile_menu_style = get_option( 'divi_px_menu_images' ) ;
		if ( $divi_mobile_menu_style != '' ){ 
			$divi_mobile_menu_style = get_option( 'divi_px_menu_images' ) ;
		}else{
			$divi_mobile_menu_style = 'm_style1' ;
		}
		$classes[] = 'px_mm_'.$divi_mobile_menu_style;
	}


	if ( 'on' === et_get_option( 'divi_back_to_top', 'on' ) ){
		/*---------Back To TOP---------------*/
		$divi_px_list_btt = get_option( 'divi_px_list_btt' ) ;
		if ( $divi_px_list_btt != '' ){ 
			$divi_px_list_btt = get_option( 'divi_px_list_btt' ) ;
		}else{
			$divi_px_list_btt = '1' ;
		}
		$classes[] = 'px_custom_back_to_top px_custom_back_to_top--style-'.$divi_px_list_btt;
	}
	return $classes;
}
add_action('body_class','px_body_class');


/*---------Hemburger Menu---------------*/
function px_list_hamburger_menu(){
    $list_hamburger_menu = array(
            'px_hamburgermenu-1' => array(
                'value' => 'px_hamburgermenu-1',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-1.gif'
            ),
            'px_hamburgermenu-2' => array(
                'value' => 'px_hamburgermenu-2',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-2.gif'
            ),
            'px_hamburgermenu-3' => array(
                'value' => 'px_hamburgermenu-3',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-3.gif'
            ),
            'px_hamburgermenu-4' => array(
                'value' => 'px_hamburgermenu-4',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-4.gif'
            ),
            'px_hamburgermenu-5' => array(
                'value' => 'px_hamburgermenu-5',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-5.gif'
            ),
            'px_hamburgermenu-6' => array(
                'value' => 'px_hamburgermenu-6',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-6.gif'
            ),
            'px_hamburgermenu-7' => array(
                'value' => 'px_hamburgermenu-7',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-7.gif'
            ),
            'px_hamburgermenu-8' => array(
                'value' => 'px_hamburgermenu-8',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-8.gif'
            ),
            'px_hamburgermenu-9' => array(
                'value' => 'px_hamburgermenu-9',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-9.gif'
            ),
            'px_hamburgermenu-10' => array(
                'value' => 'px_hamburgermenu-10',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-10.gif'
            ),
            'px_hamburgermenu-11' => array(
                'value' => 'px_hamburgermenu-11',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-11.gif'
            ),
            'px_hamburgermenu-12' => array(
                'value' => 'px_hamburgermenu-12',
                'img' => get_stylesheet_directory_uri(). '/assets/img/mobile_menu_icons/px_hamburgermenu-12.gif'
            )
        );
        $divi_px_list_hamburger_menu = get_option( 'divi_px_list_hamburger_menu' ) ;
        if ( $divi_px_list_hamburger_menu != '' ){ 
            $divi_px_list_hamburger_menu = get_option( 'divi_px_list_hamburger_menu' ) ;
        }else{
            $divi_px_list_hamburger_menu = 'px_hamburgermenu-1' ;
        }
    
         foreach( $list_hamburger_menu as $images ) :?>
<div class="loader_div">
    <input type="radio" name="divi_px_list_hamburger_menu" value="<?php esc_attr_e( $images['value'] ); ?>" <?php
        checked( esc_attr($divi_px_list_hamburger_menu), $images['value'] ); ?> class="loader_select"/>
    <img src="<?php echo esc_attr($images['img']); ?>" alt="<?php echo esc_url($images['value']); ?>"
        alt="<?php echo esc_attr($images['value']); ?>" />
</div>
<?php endforeach;
}


/*---------Back To TOP---------------*/
function PX_allowed_html() {
	$allowed_tags = array(
		'a' => array(
			'class' => array(),
			'href'  => array(),
			'rel'   => array(),
			'title' => array(),
			'target' => array(),
		),
		'br' => array(),
		'b' => array(),
		'h1' => array(),
		'style' => array(),
		'img' => array(
			'alt'    => array(),
			'class'  => array(),
			'height' => array(),
			'src'    => array(),
			'width'  => array(),
		),
		'p' => array(
			'class' => array(),
		),
	);
	
	return $allowed_tags;
}

function px_list_backtotop_styles(){
    $backtotop = array(
            'btt1' => array(
                'value' => '1',
                'img' => get_stylesheet_directory_uri(). '/assets/img/backtotop/style-1.gif'
            ),
            'btt2' => array(
                'value' => '2',
                'img' => get_stylesheet_directory_uri(). '/assets/img/backtotop/style-2.gif'
            ),
            'btt3' => array(
                'value' => '3',
                'img' => get_stylesheet_directory_uri(). '/assets/img/backtotop/style-3.gif'
            ),
            'btt4' => array(
                'value' => '4',
                'img' => get_stylesheet_directory_uri(). '/assets/img/backtotop/style-4.gif'
            ),
            'btt5' => array(
                'value' => '5',
                'img' => get_stylesheet_directory_uri(). '/assets/img/backtotop/style-5.gif'
            ),
            'btt6' => array(
                'value' => '6',
                'img' => get_stylesheet_directory_uri(). '/assets/img/backtotop/style-6.gif'
            ),
            'btt7' => array(
                'value' => '7',
                'img' => get_stylesheet_directory_uri(). '/assets/img/backtotop/style-7.gif'
            ),
        );
        $divi_px_list_btt = get_option( 'divi_px_list_btt' ) ;
        if ( $divi_px_list_btt != '' ){ 
            $divi_px_list_btt = get_option( 'divi_px_list_btt' ) ;
        }else{
            $divi_px_list_btt = '1' ;
        }
        foreach( $backtotop as $images ) :?>
<div class="loader_div_btt">
    <input type="radio" name="divi_px_list_btt" value="<?php esc_attr_e( $images['value'] ); ?>" <?php checked(
        esc_attr($divi_px_list_btt), $images['value'] ); ?> class="loader_select_btt"/>
    <img src="<?php echo esc_attr($images['img']); ?>" alt="<?php echo esc_url($images['value']); ?>"
        alt="<?php echo esc_attr($images['value']); ?>" />
</div>
<?php endforeach;
        
    }


add_action('wp_ajax_save_epanel', 'px_et_epanel_save_callback_new');
function px_et_epanel_save_callback_new($source)
{
	et_core_nonce_verified_previously();
	$divi_PX_pre_preloader_images_val = isset( $_POST[ 'divi_pxpre_preloader_images' ] ) ? sanitize_text_field( $_POST['divi_pxpre_preloader_images'] ) : '';
	$divi_PX_list_hamburger_menu_val = isset( $_POST[ 'divi_px_list_hamburger_menu' ] ) ? sanitize_text_field( $_POST['divi_px_list_hamburger_menu'] ) : '';
	$divi_PX_list_btt_val = isset( $_POST[ 'divi_px_list_btt' ] ) ? sanitize_text_field( $_POST['divi_px_list_btt'] ) : '';
	$divi_px_menu_images = isset( $_POST[ 'divi_px_menu_images' ] ) ? sanitize_text_field( $_POST['divi_px_menu_images'] ) : '';
	
	$divi_cursor_images_val = isset( $_POST[ 'divi_cursor_images' ] ) ? sanitize_text_field( $_POST['divi_cursor_images'] ) : '';
	
	update_option('divi_px_list_hamburger_menu',$divi_PX_list_hamburger_menu_val);
	update_option('divi_pxpre_preloader_images',$divi_PX_pre_preloader_images_val);
	update_option('divi_px_list_btt',$divi_PX_list_btt_val);
	update_option('divi_px_menu_images',$divi_px_menu_images);
	
	update_option('divi_cursor_images', $divi_cursor_images_val);
}



if (!function_exists('px_get_cursor_styles')) {
    function px_get_cursor_styles() {

        $px_cursor_images = array(
            'px_cursor1' => get_stylesheet_directory_uri() . '/assets/cursor/cursor-1.gif',
            'px_cursor2' => get_stylesheet_directory_uri() . '/assets/cursor/cursor-2.gif',
            'px_cursor3' => get_stylesheet_directory_uri() . '/assets/cursor/cursor-3.gif',
            'px_cursor4' => get_stylesheet_directory_uri() . '/assets/cursor/cursor-4.gif',
            'px_cursor5' => get_stylesheet_directory_uri() . '/assets/cursor/cursor-5.gif',
        );

        return $px_cursor_images;
    }
}

if (!function_exists('px_list_cursor_styles')) {
    function px_list_cursor_styles() {
        $px_cursor_images = px_get_cursor_styles();
        
        $selected = get_option('divi_cursor_images');
        
        if (empty($selected) || !isset($px_cursor_images[$selected])) {
            $selected = 'px_cursor2'; 
        }
        
        ?>
<style>
    .px-cursor-wrapper {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        padding: 15px 0;
    }

    .px-cursor-card {
        position: relative;
        width: 100px;
        height: 100px;
        cursor: pointer;
    }

    .px-cursor-card-input {
        position: absolute;
        top: -10px;
        left: 0;
        width: 16px;
        height: 16px;
        z-index: 10;
        margin: 0;
        cursor: pointer;
    }

    .px-cursor-card-inner {
        width: 100%;
        height: 100%;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid #eee;
        transition: all 0.3s ease;
    }

    .px-cursor-card-input:checked+.px-cursor-card-inner {
        border-color: #2563eb;
        background: #fff;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

    .px-cursor-card img {
        max-width: 60%;
        max-height: 60%;
        object-fit: contain;
    }
</style>
<div class="px-cursor-wrapper">
    <?php foreach ($px_cursor_images as $key => $img) { ?>
    <label class="px-cursor-card">
        <input type="radio" name="divi_cursor_images" class="px-cursor-card-input"
            data-customize-setting-link="divi_cursor_images" value="<?php echo esc_attr($key); ?>" <?php
            checked($selected, $key); ?> />
        <div class="px-cursor-card-inner">
            <img src="<?php echo esc_url($img); ?>" />
        </div>
    </label>
    <?php } ?>
</div>
<?php
    }
}
/* Change Footer Admin Text */

function px_change_footer_admin($text) {

    return sprintf(
        '<a href="%1$s"  target="_blank">%2$s</a>',
        esc_html(PX_THEMEAUTHOR_URL),
        sprintf(
            '%s Child Theme Design By %s',
            esc_html(PX_THEMENAME),
            esc_html(PX_THEMEAUTHOR)
        )
    );
}

add_filter('admin_footer_text', 'px_change_footer_admin');


// Output custom back-to-top button HTML
function px_custom_back_to_top_output() {

    if ( et_get_option( 'divi_PX__btt_custom_enable', 'off' ) !== 'on' ) {
        return;
    }

    $icon_url = et_get_option( 'divi_PX__btt_icon', '' );
    $radius   = et_get_option( 'divi_PX__btt_radius', '12' );
    ?>
    <div id="px_tt-scroll-btn">
        <svg width="100%" height="100%" viewBox="0 0 100 100" preserveAspectRatio="none">
            <rect id="px_tt-progress-path"
                x="2" y="2" width="96" height="96"
                rx="<?php echo esc_attr( $radius ); ?>"
                ry="<?php echo esc_attr( $radius ); ?>" />
        </svg>

        <?php if ( $icon_url ) : ?>
            <img src="<?php echo esc_url( $icon_url ); ?>" alt="<?php esc_attr_e( 'Back to top', 'px' ); ?>">
        <?php else : ?>
            <span class="px_tt-arrow">&#8593;</span>
        <?php endif; ?>
    </div>
    <?php
}
add_action( 'wp_footer', 'px_custom_back_to_top_output' );


// Convert HEX color to RGB/RGBA
function px_hex2rgba( $color, $opacity = false ) {

    $default = 'rgb(0,0,0)';

    if ( empty( $color ) ) {
        return $default;
    }

    if ( $color[0] === '#' ) {
        $color = substr( $color, 1 );
    }

    if ( strlen( $color ) === 6 ) {
        $hex = array( $color[0].$color[1], $color[2].$color[3], $color[4].$color[5] );
    } elseif ( strlen( $color ) === 3 ) {
        $hex = array( $color[0].$color[0], $color[1].$color[1], $color[2].$color[2] );
    } else {
        return $default;
    }

    $rgb = array_map( 'hexdec', $hex );

    if ( $opacity ) {
        if ( abs( $opacity ) > 1 ) {
            $opacity = 1.0;
        }
        return 'rgba(' . implode(',', $rgb) . ',' . $opacity . ')';
    }

    return 'rgb(' . implode(',', $rgb) . ')';
}

// Enqueue custom back-to-top assets
function px_enqueue_btt_custom() {

    if ( et_get_option( 'divi_PX__btt_custom_enable', 'off' ) !== 'on' ) {
        return;
    }

    // Pass configuration to JS
    wp_localize_script( 'px-btt-custom-js', 'px_tt_btt_config', array(
        'bg_color'       => et_get_option( 'divi_PX__btt_bg_color', '#f9a392' ),
        'icon_color'     => et_get_option( 'divi_PX__btt_icon_color', '#ffffff' ),
        'progress_color' => et_get_option( 'divi_PX__btt_progress', '#000000' ),
        'btn_size'       => et_get_option( 'divi_PX__btt_size', '70' ),
        'icon_size'      => et_get_option( 'divi_PX__btt_icon_size', '22' ),
        'radius'         => et_get_option( 'divi_PX__btt_radius', '12' ),
        'speed'          => et_get_option( 'divi_PX__btt_speed', '800' ),
        'img_width'      => et_get_option( 'divi_PX__btt_img_width', '50' ),
        'img_height'     => et_get_option( 'divi_PX__btt_img_height', '50' ),
    ) );
}
add_action( 'wp_enqueue_scripts', 'px_enqueue_btt_custom' );


// Add custom body class in admin for activation panel page

function add_admin_body_class($classes) {

    $screen = get_current_screen();

    if ($screen && $screen->id === 'settings_page_wc_am_client_' . PX_ORDER_NO . '_dashboard') {
        $classes .= ' px_activation_panel';
    }

    return $classes;
}
add_filter('admin_body_class', 'add_admin_body_class');

// Show welcome notice after theme activation
add_action( 'after_switch_theme', 'px_set_welcome_notice' );

// Set transient flag for welcome notice
function px_set_welcome_notice() {
    set_transient( 'px_theme_show_welcome_notice', true, 3600 );
}

// Output dynamic styles in head
function px_dynamic_style() {

    // Hamburger menu option
    $divi_PX_hamburger_menu_option = et_get_option( 'divi_PX_hamburger_menu_option', 'on' );

    // Load hamburger menu style
    if ( $divi_PX_hamburger_menu_option === 'on' ) {
        $divi_px_list_hamburger_menu = get_option( 'divi_px_list_hamburger_menu' );
        if ( empty( $divi_px_list_hamburger_menu ) ) {
            $divi_px_list_hamburger_menu = 'px_hamburgermenu-1';
        }
        include get_stylesheet_directory() . '/extra-options/hamburgermenu/' . $divi_px_list_hamburger_menu . '.php';
    }

    // Back to top options
    $divi_back_to_top   = et_get_option( 'divi_back_to_top', 'off' );
    $custom_btt_enable  = et_get_option( 'divi_PX__btt_custom_enable', 'off' );

    // Load default back-to-top style if custom disabled
    if ( $divi_back_to_top === 'on' && $custom_btt_enable !== 'on' ) {
        $divi_px_list_btt = get_option( 'divi_px_list_btt' );
        if ( empty( $divi_px_list_btt ) ) {
            $divi_px_list_btt = '1';
        }
        include get_stylesheet_directory() . '/extra-options/backtotop/px_backtotop_' . $divi_px_list_btt . '.php';
    }
}
add_action( 'wp_head', 'px_dynamic_style' );

// Add body class for mobile menu styling
function px_mobile_menu_body_class( $classes ) {

    $divi_PX_Mobile_Menu_option = et_get_option( 'divi_PX_Mobile_Menu_option', 'on' );

    		/*---------Hemburger Menu---------------*/
		$divi_px_list_hamburger_menu = get_option( 'divi_px_list_hamburger_menu' ) ;
		
		if ( $divi_px_list_hamburger_menu != '' ){ 
			$divi_px_list_hamburger_menu = get_option( 'divi_px_list_hamburger_menu' ) ;
		}else{
			$divi_px_list_hamburger_menu = 'px_hamburgermenu-1' ;
		}
		
		$classes[] = 'px_hamburger_menu style-'.$divi_px_list_hamburger_menu;

    return $classes;
	
		
}
add_filter( 'body_class', 'px_mobile_menu_body_class' );

// Output footer dynamic CSS variables and color panel
function px_footer_opt() {
    ?>
    <style type="text/css">
    :root {
        /* Preserve old variables for DCT Old Theme to Divi 5 upgrade */ 
        --color-1: <?php echo esc_attr( et_get_option( 'divi_PX_color_palette_01', '#fa7c04' ) ); ?>;
        --color-2: <?php echo esc_attr( et_get_option( 'divi_PX_color_palette_02', '#3d3d3d' ) ); ?>;
    }
    </style>
    <?php

    // Include color options panel if enabled
    if ( 'on' === et_get_option( 'divi_PX_show_color_option', 'off' ) ) {
        include get_stylesheet_directory() . '/extra-options/px_opt.php';
    }
    
}
add_action( 'wp_footer', 'px_footer_opt' );
