HEX
Server: Apache
System: Linux cp4.skywebbox.com 5.14.0-503.15.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 28 07:25:19 EST 2024 x86_64
User: alfouzantranspor (1054)
PHP: 8.3.23
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/alfouzantranspor/www/wp-content/themes/cargo-transport/functions.php
<?php
/**
 * Theme functions and definitions
 *
 * @package Cargo Transport
 */ 

if ( ! function_exists( 'cargo_transport_enqueue_styles' ) ) :
	/**
	 * Load assets.
	 *
	 * @since 1.0.0
	 */
	function cargo_transport_enqueue_styles() {
		wp_enqueue_style( 'cargo-transport-block-patterns-style-frontend', get_theme_file_uri('/css/block-frontend.css') );
		wp_enqueue_style( 'logistic-transport-bootstrap-css', get_template_directory_uri().'/css/bootstrap.css' );
		wp_enqueue_style( 'cargo-transport-style-parent', get_template_directory_uri() . '/style.css' );
		wp_enqueue_style( 'cargo-transport-style', get_stylesheet_directory_uri() . '/style.css', array( 'cargo-transport-style-parent' ), '1.0.0' );
	    require get_theme_file_path( '/tc-style.php' );
		wp_add_inline_style( 'cargo-transport-style',$cargo_transport_custom_css );

		require get_parent_theme_file_path( '/tc-style.php' );
		wp_add_inline_style( 'cargo-transport-style-parent',$logistic_transport_custom_css );
	}
endif;
add_action( 'wp_enqueue_scripts', 'cargo_transport_enqueue_styles');

/**
 * Enqueue block editor style
 */
function cargo_transport_block_editor_styles() {
	wp_enqueue_style( 'logistic-transport-font', logistic_transport_font_url(), array() );
	wp_enqueue_style( 'cargo-transport-block-patterns-style-editor', get_theme_file_uri( '/css/block-editor.css' ), false, '1.0', 'all' );
    wp_enqueue_style( 'logistic-transport-bootstrap-style', get_template_directory_uri().'/css/bootstrap.css' );
    wp_enqueue_style( 'logistic-transport-font-awesome-css', get_template_directory_uri().'/css/fontawesome-all.css' );
}
add_action( 'enqueue_block_editor_assets', 'cargo_transport_block_editor_styles' );

function cargo_transport_customize_register() {
	global $wp_customize;
	$wp_customize->remove_setting( 'logistic_transport_theme_color_first' );
	$wp_customize->remove_control( 'logistic_transport_theme_color_first' );
	$wp_customize->remove_setting( 'logistic_transport_theme_color_second' );
	$wp_customize->remove_control( 'logistic_transport_theme_color_second' );
	$wp_customize->remove_section( 'logistic_transport_about_theme' );
	$wp_customize->remove_setting( 'logistic_transport_menu_settings_premium_features' );
	$wp_customize->remove_control( 'logistic_transport_menu_settings_premium_features' );
	$wp_customize->remove_setting( 'logistic_transport_post_settings_premium_features' );
	$wp_customize->remove_control( 'logistic_transport_post_settings_premium_features' );
	$wp_customize->remove_setting( 'logistic_transport_services_category' );
	$wp_customize->remove_control( 'logistic_transport_services_category' );
	$wp_customize->remove_setting( 'logistic_transport_services_button_text' );
	$wp_customize->remove_control( 'logistic_transport_services_button_text' );
	$wp_customize->remove_setting( 'logistic_transport_service_hide_show' );
	$wp_customize->remove_control( 'logistic_transport_service_hide_show' );

	// Add the Theme Color Option section.
	$wp_customize->add_setting( 'cargo_transport_primary_theme_color', array(
	    'default' => '#ff8700',
	    'sanitize_callback' => 'sanitize_hex_color',
  	));
	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'cargo_transport_primary_theme_color', array(
  		'label' => __('Theme Color Option 1','cargo-transport'),
	    'section' => 'logistic_transport_typography',
	    'settings' => 'cargo_transport_primary_theme_color',
		'priority' => 1,
  	)));

	$wp_customize->add_setting( 'cargo_transport_secondary_theme_color', array(
	    'default' => '#1d2027',
	    'sanitize_callback' => 'sanitize_hex_color',
  	));
	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'cargo_transport_secondary_theme_color', array(
  		'label' => __('Theme Color Option 2','cargo-transport'),
	    'section' => 'logistic_transport_typography',
	    'settings' => 'cargo_transport_secondary_theme_color',
		'priority' => 2,
  	)));

	
	//About Section
		$wp_customize->add_section( 'cargo_transport_about_theme' , array(
	    	'title' => esc_html__( 'About Theme', 'cargo-transport' ),
	    	'priority' => 10,
		) );

		$wp_customize->add_setting('cargo_transport_demo_link',array(
			'sanitize_callback'	=> 'sanitize_text_field'
		));
		$wp_customize->add_control('cargo_transport_demo_link',array(
			'type'=> 'hidden',
			'description' => "<h3>". esc_html__('Theme Demo','cargo-transport') ."</h3><p>". esc_html__('Our premium version of Cargo Transport has unlimited sections with advanced control fields. Dedicated support and no limititation in any field.','cargo-transport') ."</p> <a target='_blank' href='". esc_url('https://preview.themescaliber.com/cargo-transport-pro/') ." '>". esc_html__('View Demo','cargo-transport') ."</a>",
			'section'=> 'cargo_transport_about_theme'
		));
		
		$wp_customize->add_setting('cargo_transport_doc_link',array(
			'sanitize_callback'	=> 'sanitize_text_field'
		));
		$wp_customize->add_control('cargo_transport_doc_link',array(
			'type'=> 'hidden',
			'description' => "<h3>". esc_html__('Theme Documentation','cargo-transport') ."</h3><p>". esc_html__('We have well prepared documentation that provides the general guidelines and suggestions needed for this theme.','cargo-transport') ."</p> <a target='_blank' href='". esc_url('https://preview.themescaliber.com/doc/free-cargo-transport/') ." '>". esc_html__('View Documentation','cargo-transport') ."</a>",
			'section'=> 'cargo_transport_about_theme'
		));

		$wp_customize->add_setting('cargo_transport_forum_link',array(
			'sanitize_callback'	=> 'sanitize_text_field'
		));
		$wp_customize->add_control('cargo_transport_forum_link',array(
			'type'=> 'hidden',
			'description' => "<h3>". esc_html__('Theme Support','cargo-transport') ."</h3><p>". esc_html__('Regarding any theme issue, we offer 24/7 support. You can get assistance from our support staff in resolving any problem. Please get in touch with us.','cargo-transport') ."</p><a target='_blank' href='". esc_url('https://wordpress.org/support/theme/cargo-transport/') ." '>". esc_html__('Support Forum','cargo-transport') ."</a>",
			'section'=> 'cargo_transport_about_theme'
		));

		$wp_customize->add_setting('cargo_transport_review_link',array(
			'sanitize_callback'	=> 'sanitize_text_field'
		));
		$wp_customize->add_control('cargo_transport_review_link',array(
			'type'=> 'hidden',
			'description' => "<h3>". esc_html__('Theme Review','cargo-transport') ."</h3><p>". esc_html__('If you enjoy using our theme, we’d love to hear your feedback. please leave us a review.','cargo-transport') ."</p><a target='_blank' href='". esc_url('https://wordpress.org/support/theme/cargo-transport/reviews/#new-post') ." '>". esc_html__('Rate & Review','cargo-transport') ."</a>",
			'section'=> 'cargo_transport_about_theme'
		));			

		$wp_customize->add_setting( 'cargo_transport_menu_settings_premium_features',array(
        'sanitize_callback' => 'sanitize_text_field'
    	));
    	$wp_customize->add_control('cargo_transport_menu_settings_premium_features', array(
	    	'type'=> 'hidden',
	        'description' => "<h3>". esc_html__('More Features in the Premium Version!','cargo-transport') ."</h3>
	        	<ul>
	        		<li>". esc_html__('Menu Background Colors','cargo-transport') ."</li>
	        		<li>". esc_html__('Menu Item Fonts','cargo-transport') ."</li>
	        		<li>". esc_html__('Responsive Menu Colors','cargo-transport') ."</li>
	        		<li>". esc_html__('Header Search Icons Colors','cargo-transport') ."</li>
	        		<li>". esc_html__('... and Other Premium Features','cargo-transport') ."</li>
	        	</ul>
	        	<a target='_blank' href='". esc_url('https://www.themescaliber.com/products/cargo-wordpress-theme/') ." '>". esc_html__('Upgrade Now','cargo-transport') ."</a>",
        	'section' => 'logistic_transport_header',
			'priority' => 1,
        	)
    	);

	    $wp_customize->add_setting( 'cargo_transport_post_settings_premium_features',array(
        'sanitize_callback' => 'sanitize_text_field'
	    ));
	    $wp_customize->add_control('cargo_transport_post_settings_premium_features', array(
	    	'type'=> 'hidden',
	        'description' => "<h3>". esc_html__('More Features in the Premium Version!','cargo-transport') ."</h3>
	        	<ul>
	        		<li>". esc_html__('Section Heading Option','cargo-transport') ."</li>
	        		<li>". esc_html__('Animated Elements Colors','cargo-transport') ."</li>
	        		<li>". esc_html__('... and Other Premium Features','cargo-transport') ."</li>
	        	</ul>
	        	<a target='_blank' href='". esc_url('https://www.themescaliber.com/products/cargo-wordpress-theme/') ." '>". esc_html__('Upgrade Now','cargo-transport') ."</a>",
	        'section' => 'logistic_transport_blog_post',
			'priority' => 1,
	        )
	    );
}
add_action( 'customize_register', 'cargo_transport_customize_register', 11 );

require_once( ABSPATH . WPINC . '/class-wp-customize-section.php' );

class Cargo_Transport_Customize_Section_Pro extends WP_Customize_Section {

    /**
     * Outputs the Underscore.js template.
     *
     * @since  1.0.0
     * @access public
     * @return void
     */
    protected function render_template() { ?>

        <li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
            <h3 class="accordion-section-title">
                {{ data.title }}

                <# if ( data.pro_text && data.pro_url ) { #>
                    <a href="{{ data.pro_url }}" class="button button-secondary alignright" target="_blank">{{ data.pro_text }}</a>
                <# } #>
            </h3>
        </li>
    <?php }
}


/**
 * Singleton class for handling the theme's customizer integration.
 *
 * @since  1.0.0
 * @access public
 */
final class Cargo_Transport_Customize {

    /**
     * Returns the instance.
     *
     * @since  1.0.0
     * @access public
     * @return object
     */
    public static function get_instance() {

        static $instance = null;

        if ( is_null( $instance ) ) {
            $instance = new self;
            $instance->setup_actions();
        }

        return $instance;
    }

    /**
     * Constructor method.
     *
     * @since  1.0.0
     * @access private
     * @return void
     */
    private function __construct() {}

    /**
     * Sets up initial actions.
     *
     * @since  1.0.0
     * @access private
     * @return void
     */
    private function setup_actions() {

        // Register panels, sections, settings, controls, and partials.
        add_action( 'customize_register', array( $this, 'sections' ) );

        // Register scripts and styles for the controls.
        add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ), 0 );
    }

    /**
     * Sets up the customizer sections.
     *
     * @since  1.0.0
     * @access public
     * @param  object  $manager
     * @return void
     */
    public function sections( $manager ) {

        // Register custom section types.
        $manager->register_section_type( 'Cargo_Transport_Customize_Section_Pro' );

    }

    /**
     * Loads theme customizer CSS.
     *
     * @since  1.0.0
     * @access public
     * @return void
     */

    public function enqueue_control_scripts() {
        wp_enqueue_style( 'cargo_transport-customize-controls', get_stylesheet_directory_uri() . '/css/customize-controls-child.css' );
    }
}

// Doing this customizer thang!
Cargo_Transport_Customize::get_instance();

/* Theme Setup */
if ( ! function_exists( 'cargo_transport_setup' ) ) :

function cargo_transport_setup() {

	$GLOBALS['content_width'] = apply_filters( 'cargo_transport_content_width', 640 );

	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'title-tag' );
	add_theme_support( 'wp-block-styles' );
	add_theme_support( 'align-wide' );
	add_theme_support( 'custom-logo', array(
		'height'      => 240,
		'width'       => 240,
		'flex-height' => true,
	) );
	add_image_size('cargo-transport-homepage-thumb',240,145,true);

	add_theme_support( 'custom-background', array(
		'default-color' => 'f1f1f1'
	) );

	add_theme_support ('html5', array (
        'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
    ) );

	add_theme_support('responsive-embeds');

	add_theme_support( 'post-formats', array('image','video','gallery','audio',) );

	add_editor_style( array( 'css/editor-style.css' ) );
}

endif;
add_action( 'after_setup_theme', 'cargo_transport_setup' );

function cargo_transport_widgets_init() {
	register_sidebar( array(
		'name'          => __( 'Blog Sidebar', 'cargo-transport' ),
		'description'   => __( 'Appears on blog page sidebar', 'cargo-transport' ),
		'id'            => 'sidebar-1',
		'before_widget' => '<aside id="%1$s" class="widget %2$s mb-4 p-2">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title pt-0">',
		'after_title'   => '</h3>',
	) );
}
add_action( 'widgets_init', 'cargo_transport_widgets_init' );

function cargo_transport_enqueue_comments_reply() {
    if( is_singular() && comments_open() && ( get_option( 'thread_comments' ) == 1) ) {
        wp_enqueue_script( 'comment-reply', '/wp-includes/js/comment-reply.min.js', array(), false, true );
    }
}
add_action( 'wp_enqueue_scripts', 'cargo_transport_enqueue_comments_reply' );

add_action( 'init', 'cargo_transport_remove_action');
function cargo_transport_remove_action() {
    remove_action( 'admin_menu','logistic_transport_gettingstarted' );
    remove_action( 'admin_notices','logistic_transport_activation_notice' );
}
function cargo_transport_mysetup() {
	// URL DEFINES
	define('CARGO_TRANSPORT_SUPPORT',__('https://wordpress.org/support/theme/cargo-transport/','cargo-transport'));
	define('CARGO_TRANSPORT_REVIEW',__('https://wordpress.org/support/theme/cargo-transport/reviews/','cargo-transport'));
	define('CARGO_TRANSPORT_BUY_NOW',__('https://www.themescaliber.com/products/cargo-wordpress-theme','cargo-transport'));
	define('CARGO_TRANSPORT_LIVE_DEMO',__('https://preview.themescaliber.com/cargo-transport-pro/','cargo-transport'));
	define('CARGO_TRANSPORT_PRO_DOC',__('https://preview.themescaliber.com/doc/cargo-transport-pro/','cargo-transport'));
	define('CARGO_TRANSPORT_CHILD_THEME',__('https://developer.wordpress.org/themes/advanced-topics/child-themes/','cargo-transport'));
	define('CARGO_TRANSPORT_THEME_URL',__('https://www.themescaliber.com/products/free-cargo-wordpress-theme', 'cargo-transport'));
	define('CARGO_TRANSPORT_FREE_THEME_DOC',__('https://preview.themescaliber.com/doc/free-cargo-transport/', 'cargo-transport'));

	if ( ! defined( 'LOGISTIC_TRANSPORT_PRO_NAME' ) ) {
		define( 'LOGISTIC_TRANSPORT_PRO_NAME', esc_html__( 'Cargo Pro Theme', 'cargo-transport' ));
	}
	if ( ! defined( 'LOGISTIC_TRANSPORT_PRO_URL' ) ) {
		define( 'LOGISTIC_TRANSPORT_PRO_URL', esc_url('https://www.themescaliber.com/products/cargo-wordpress-theme/'));
	}
	/* Block Pattern */
	require get_theme_file_path() . '/block-patterns.php';

// Dashboard Theme Notification
	global $pagenow;

	if (
			is_admin()
			&&
			('themes.php' == $pagenow)
			// &&
			// isset( $_GET['activated'] )
		) {
			add_action('admin_notices', 'cargo_transport_activation_notice');
		}
	}
add_action( 'after_setup_theme', 'cargo_transport_mysetup' );

// Dashboard Theme Notification   
function cargo_transport_activation_notice() {
	$cargo_transport_meta = get_option( 'cargo_transport_admin_notice' );

	if (!$cargo_transport_meta) {
	echo '<div id="cargo-transport-welcome-notice" class="notice is-dismissible logistic-transport-notice">';
		echo '<div class="logistic-transport-banner">';
			echo '<div class="logistic-transport-text">';
				echo '<h2>' . esc_html__( 'Thanks For Installing the "Cargo Transport" Theme !', 'cargo-transport' ) . '</h2>';
				echo '<p>' . esc_html__( 'We’re excited to help you get started with your new theme! Set up your website quickly and easily by importing our demo content and customizing it to suit your needs.', 'cargo-transport' ) . '</p>';
				echo '<div class="logistic-transport-buttons">';
					echo '<a href="' . esc_url( admin_url( 'themes.php?page=cargo_transport_guide' ) ) . '">' . esc_html__( 'Demo Import', 'cargo-transport' ) . '</a>';
					echo '<a href="'. esc_url( 'https://preview.themescaliber.com/doc/free-cargo-transport/' ) .'" target=_blank>' . esc_html__( 'Documentation', 'cargo-transport' ) . '</a>';
					echo '<a href="'. esc_url( 'https://www.themescaliber.com/products/cargo-wordpress-theme/' ) .'" target=_blank>' . esc_html__( 'Get Premium', 'cargo-transport' ) . '</a>';
					echo '<a class="bundle_btn" href="'. esc_url( 'https://www.themescaliber.com/products/wordpress-theme-bundle' ) .'" target=_blank>' . esc_html__( 'Bundle of 220+ Themes at $99', 'cargo-transport' ) . '</a>';
					
				echo '</div>';
			echo '</div>';
			echo '<div class="logistic-transport-image">';
				echo '<img src="' . esc_url(get_theme_file_uri()) . '/images/demo-preview.png">';
			echo '</div>';
		echo '</div>';
    echo '</div>';
}
}

function cargo_transport_credit_link() {
    echo "<a href=".esc_url(CARGO_TRANSPORT_THEME_URL)." target='_blank'>".esc_html__('Cargo WordPress Theme','cargo-transport')."</a>";
}

/* Implement the get started page */
require get_theme_file_path() . '/inc/dashboard/getstart.php';

// Admin notice code START
function cargo_transport_dismissed_notice() {
	update_option( 'cargo_transport_admin_notice', true );
}
add_action( 'wp_ajax_cargo_transport_dismissed_notice', 'cargo_transport_dismissed_notice' );

//After Switch theme function
add_action('after_switch_theme', 'cargo_transport_getstart_setup_options');
function cargo_transport_getstart_setup_options () {
    update_option('cargo_transport_admin_notice', false );
}
// Admin notice code END

// woocommerce page function
add_filter( 'woocommerce_enable_setup_wizard', '__return_false' );