HEX
Server: nginx/1.27.1
System: Linux in-4 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User: ilikadirect (1186)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v6964/iskcon/public_html/wp-content/themes/tow-temple/tow-settings/main-page.php
<?php

global $tow_settings; 
global $tabs; 

 //wp_enqueue_style( 'bootstrap-5', 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css' );
 wp_enqueue_style( 'template-custom-css', get_template_directory_uri() . '/tow-settings/template/css/custom.css' );

/**
 * Enqueue admin styles on the CMB2 options page.
 */
add_action( 'my_custom_admin_enqueue_scripts', 'my_custom_cmb2_admin_styles' );
function my_custom_cmb2_admin_styles( $hook_suffix ) {
   global $tabs;
    //var_dump($tabs);
    // Only load on our custom options page
    if ( isset( $_GET['page'] ) && array_key_exists($_GET['page'], $tabs) ) {
       wp_enqueue_style( 'bootstrap-5', 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css' );
	   wp_enqueue_style( 'bootstrap-icons', 'https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css', array(), null );
       wp_enqueue_script( 'bootstrap-5-js', 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js', array('jquery'), null, true );
	   wp_enqueue_script( 'template-custom-js', get_template_directory_uri() . '/tow-settings/template/js/custom.js', array('jquery'), null, true );
    }
}

/**
 * Hook in and register a metabox to handle a theme options page and adds a menu item.
 */
    
	include_once(dirname( __FILE__ ) . '/pages/main/fields.php');
	include_once(dirname( __FILE__ ) . '/pages/general/fields.php');
	include_once(dirname( __FILE__ ) . '/pages/header/fields.php');
	include_once(dirname( __FILE__ ) . '/pages/banner-slider/fields.php');
	include_once(dirname( __FILE__ ) . '/pages/footer/fields.php');
    include_once(dirname( __FILE__ ) . '/pages/social/fields.php');
    include_once(dirname( __FILE__ ) . '/pages/import/fields.php');


/**
 * Display custom admin notice after saving options.
 */
add_action( 'cmb2_form_success_notices', 'my_custom_form_save_notice' );
function my_custom_form_save_notice() {
    
    // Check if we are on the correct options page and if the settings were updated
    if ( isset( $_GET['page'] )  && isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] ) {
	
        echo '<div class="alert alert-success mt-2">';
        echo '' . esc_html__( 'Settings saved successfully!', 'cmb2' ) . '';
        echo '</div>';
    }
}

/**
 * A CMB2 options-page display callback override which adds tab navigation among
 * CMB2 options pages which share this same display callback.
 *
 * @param CMB2_Options_Hookup $cmb_options The CMB2_Options_Hookup object.
 */
function tow_page_display( $cmb_options ) {
//print "=================================";

/*
// Loop through all registered meta boxes
foreach ( CMB2_Boxes::get_all() as $cmb_id => $cmb_object ) {
    echo '<h3>' . esc_html( $cmb_id ) . '</h3>';
    
    // Get meta box fields
    $fields = $cmb_object->prop( 'fields' );
    
    foreach ( $fields as $field ) {
        echo '<p>Field ID: ' . esc_html( $field['id'] ) . '</p>';
    }
}
*/
	global $tabs;
	$tabs = tow_options_page_tabs( $cmb_options );
	
	do_action('my_custom_admin_enqueue_scripts');

	include_once(get_template_directory()  . '/tow-settings/template/header-top.php');
	include_once(get_template_directory()  . '/tow-settings/template/header.php');

?>
    <section class="p_4 pb-0 cmb2-options-page option-<?php echo $cmb_options->option_key; ?>">
      <div class="container-xl">
	   <div class="row">
	     <?php
	     	include_once(get_template_directory()  . '/tow-settings/template/left.php');
	        include_once(get_template_directory()  . '/tow-settings/template/right.php');
	     ?>
		 
	   </div>
	</div>
   </section>

<?php
}

/**
 * Gets navigation tabs array for CMB2 options pages which share the given
 * display_cb param.
 *
 * @param CMB2_Options_Hookup $cmb_options The CMB2_Options_Hookup object.
 *
 * @return array Array of tab information.
 */
function tow_options_page_tabs( $cmb_options ) {

	$tab_group = $cmb_options->cmb->prop( 'tab_group' );
	$tabs      = array();

	foreach ( CMB2_Boxes::get_all() as $cmb_id => $cmb ) {
	    $tmpArray = array();
		if ( $tab_group === $cmb->prop( 'tab_group' ) ) {
		    
			$tmpArray['title'] = $cmb->prop( 'tab_title' ) ? $cmb->prop( 'tab_title' ) : $cmb->prop( 'title' );
			$tmpArray['icon_url'] = $cmb->prop( 'icon_url' ) ? $cmb->prop( 'icon_url' ) : '';
			$tabs[ $cmb->options_page_keys()[0] ] = $tmpArray;
		}
	}

	return $tabs;
}


add_action( 'get_header', 'get_theme_setting_values' );
function get_theme_setting_values() {
   global $tow_settings;
    //print "---------------get_theme_setting_values------------";
	
	$tow_general_options = get_option( 'tow_general_options' );
	$tow_settings['tow_general_options'] =  $tow_general_options;
	
	$tow_header_options = get_option( 'tow_header_options' );
	$tow_settings['tow_header_options'] =  $tow_header_options;
	
	$tow_banner_slider_options = get_option( 'tow_banner_slider_options' );
	$tow_settings['tow_banner_slider_options'] =  $tow_banner_slider_options;
	
    $tow_social_options = get_option( 'tow_social_options' ); 
	$tow_settings['tow_social_options'] =  $tow_social_options;
	
	$tow_footer_options = get_option( 'tow_footer_options' ); 
	$tow_settings['tow_footer_options'] =  $tow_footer_options; 
}


/***********************************  Update repeatable fields titles *********************************************/
add_action( 'cmb2_after_form', 'add_js_for_update_repeatable_titles_to_footer' );
function add_js_for_update_repeatable_titles_to_footer() {
	?>
	<script type="text/javascript">
	
	  /***** Global var outside the jquery block, used for repeater title ********/
	  var $tow_option_page_global_var;
	 
	jQuery( function( $ ) {
		
		var replaceTitles = function() {
		
			$tow_option_page_global_var.find( '.cmb-group-title' ).each( function() {
				var $this = $( this );
				var txt = $this.next().find( '[id$="title"]' ).val();
				var rowindex;

				if ( ! txt ) {
					txt = $tow_option_page_global_var.find( '[data-grouptitle]' ).data( 'grouptitle' );
					if ( txt ) {
						rowindex = $this.parents( '[data-iterator]' ).data( 'iterator' );
						txt = txt.replace( '{#}', ( rowindex + 1 ) );
					}
				}

				if ( txt ) {
					$this.text( txt );
				}
			});
		};

		var replaceOnKeyUp = function( evt ) {
			var $this = $( evt.target );
			var id = 'title';

			if ( evt.target.id.indexOf(id, evt.target.id.length - id.length) !== -1 ) {
				$this.parents( '.cmb-row.cmb-repeatable-grouping' ).find( '.cmb-group-title' ).text( $this.val() );
			}
		};

		$tow_option_page_global_var
			.on( 'cmb2_add_row cmb2_remove_row cmb2_shift_rows_complete', replaceTitles )
			.on( 'keyup', replaceOnKeyUp );

		replaceTitles();
	});
	</script>
	<?php
}