php ole.vn重定向

redirect.php
<?php
$links = array(
    'http://ole.vn/' => 'http://mebongda.net',
    'http://ole.vn/ket-qua-bong-da.html' => 'http://ketquabongda.com/',
    'http://ole.vn/ty-le-keo-bong-da.html' => 'http://bongda.wap.vn/ty-le-bong-da.html',
    'http://ole.vn/lich-thi-dau-bong-da.html' => 'http://mebongda.net/lich-thi-dau-bong-da',
    'http://ole.vn/video-bong-da.html' => 'http://mebongda.net/video-bong-da/',
    'http://ole.vn/livescore.html' => 'http://mebongda.net/livescore/',
    'http://ole.vn/bang-xep-hang-bong-da/ngoai-hang-anh-2.html' => 'http://bongda.wap.vn/bang-xep-hang-ngoai-hang-anh-anh.html',
    'http://ole.vn/bang-xep-hang-bong-da.html' => 'http://bongda.wap.vn/bang-xep-hang-bong-da.html',
    'http://ole.vn/ket-qua-bong-da/ngoai-hang-anh-2.html' => 'http://bongda.wap.vn/ket-qua-ngoai-hang-anh-anh.html',
    'http://ole.vn/lich-thi-dau-bong-da/ngoai-hang-anh-2.html' => 'http://bongda.wap.vn/lich-thi-dau-ngoai-hang-anh-anh.html',
    'http://ole.vn/lich-phat-song-bong-da.html' => 'http://mebongda.net/lich-phat-song-bong-da/',
    'http://ole.vn/bang-xep-hang-bong-da/vdqg-tay-ban-nha-4.html' => 'http://bongda.wap.vn/bang-xep-hang-vdqg-tay-ban-nha-tbn.html',
    'http://ole.vn/ket-qua-bong-da/vdqg-tay-ban-nha-4.html' => 'http://bongda.wap.vn/ket-qua-vdqg-tay-ban-nha-tbn.html',
    'http://ole.vn/bang-xep-hang-bong-da/vdqg-duc-3.html' => 'http://bongda.wap.vn/bang-xep-hang-vdqg-duc-duc.html',
    'http://ole.vn/bang-xep-hang-bong-da/vdqg-italia-6.html' => 'http://bongda.wap.vn/bang-xep-hang-vdqg-italia-ita.html',
    'http://ole.vn/bang-xep-hang-bong-da/hang-nhat-anh-184.html' => 'http://bongda.wap.vn/bang-xep-hang-hang-nhat-anh-anhb.html',
    'http://ole.vn/bang-xep-hang-bong-da/vdqg-phap-5.html' => 'http://bongda.wap.vn/bang-xep-hang-vdqg-phap-pha.html',
    'http://ole.vn/tip-bong-da.html' => 'http://tipbong.net/',
    'http://ole.vn/ket-qua-bong-da/vdqg-duc-3.html' => 'http://bongda.wap.vn/ket-qua-vdqg-duc-duc.html',
    'http://ole.vn/ket-qua-bong-da/vdqg-italia-6.html' => 'http://bongda.wap.vn/ket-qua-vdqg-italia-ita.html',
    'http://ole.vn/ket-qua-bong-da/vdqg-phap-5.html' => 'http://bongda.wap.vn/ket-qua-vdqg-phap-pha.html',
    'http://ole.vn/lich-thi-dau-bong-da/cup-c1-chau-au-21.html' => 'http://bongda.wap.vn/lich-thi-dau-cup-c1-chau-au-c1.html',
    'http://ole.vn/ket-qua-bong-da/cup-c2-chau-au-22.html' => 'http://bongda.wap.vn/ket-qua-cup-c2-chau-au-c2.html',
    'http://ole.vn/lich-thi-dau-bong-da/vdqg-tay-ban-nha-4.html' => 'http://bongda.wap.vn/lich-thi-dau-vdqg-tay-ban-nha-tbn.html',
    'http://ole.vn/ket-qua-bong-da/champions-league-21.html' => 'http://bongda.wap.vn/ket-qua-cup-c1-chau-au-c1.html',
    'http://ole.vn/tin-the-thao.html' => 'http://mebongda.net/tin-the-thao/',
    'http://ole.vn/nhan-dinh-bong-da.html' => 'http://mebongda.net/nhan-dinh-bong-da/',
    'http://ole.vn/bong-da-ngoai-hang-anh.html' => 'http://mebongda.net/bong-da-anh/',
    'http://ole.vn/cup-c1-c2-chau-au.html' => 'http://mebongda.net/bong-da-chau-au/',
    'http://ole.vn/bong-da-duc.html' => 'http://mebongda.net/bong-da-duc/',
    'http://ole.vn/bong-da-italia.html' => 'http://mebongda.net/bong-da-italia',
    'http://ole.vn/bong-da-phap.html' => 'http://mebongda.net/bong-da-phap/',
    'http://ole.vn/tin-chuyen-nhuong.html' => 'http://mebongda.net/tin-chuyen-nhuong/',
    'http://ole.vn/bong-da-trong-nuoc.html' => 'http://mebongda.net/bong-da-viet-nam/',
    'http://ole.vn/bong-da-tay-ban-nha.html' => 'http://mebongda.net/bong-da-tay-ban-nha/',
);

$uri = $_SERVER['REQUEST_URI'];
foreach ($links as $source => $target) {
    $uri = trim($uri, '/');
    if ($uri == '') {
        header('Location: '. $links['http://ole.vn/']);
        exit();
    } else if (strpos($source, $uri) !== false) {
        // redirect to target url
        header('Location: '. $target);
        exit();
    }
}

php Кеширование

Кеширование

index.php
# создаем объект
$obCache = new CPHPCache;
 
# время кеширования в секундах
$lifeTime = 30*60; 
 
# формируем идентификатор кеша в зависимости от всех параметров 
# которые могут повлиять на результирующий HTML
$cacheID = $arParams['ELEMENT_ID'].$arParams['SECTION_ID']; 
 
# если кеш есть и он ещё не истек то
if($obCache->InitCache($lifeTime, $cacheID, "/")){
    # получаем закешированные переменные
    $vars = $obCache->GetVars();
    $SECTION_TITLE = $vars["SECTION_TITLE"];
} else {
    # иначе обращаемся к базе
    $arSection = GetIBlockSection($arParams['SECTION_ID']);
    $SECTION_TITLE = $arSection["NAME"];
}
 
# добавляем пункт меню в навигационную цепочку
$APPLICATION->AddChainItem($SECTION_TITLE, $SECTION_URL."SECTION_ID=".$arParams['SECTION_ID']);
 
# начинаем буферизирование вывода
if($obCache->StartDataCache()){
 
    # выбираем из базы параметры элемента инфоблока
    if($arIBlockElement = GetIBlockElement($arParams['ELEMENT_ID'], $IBLOCK_TYPE)){
        echo "<pre>"; print_r($arIBlockElement); echo "</pre>";
    }
 
    # записываем предварительно буферизированный вывод в файл кеша
    # вместе с дополнительной переменной
    $obCache->EndDataCache(array(
        "SECTION_TITLE" => $SECTION_TITLE
        )); 
}

php WP调试<br/> <br/>将其插入wp-config.php以启用更多样化的WordPress调试

WP调试<br/> <br/>将其插入wp-config.php以启用更多样化的WordPress调试

wp-config-debug.php
<?php

define( 'WP_DEBUG', false );
define( 'WP_DEVELOPMENT_MODE', false );

if ( WP_DEBUG ) {
    define ('JETPACK_DEV_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'SCRIPT_DEBUG', true );

    if ( defined( 'DOING_AJAX' ) && DOING_AJAX || defined( 'DOING_CRON' ) && DOING_CRON ) {
        define( 'WP_DEBUG_DISPLAY', false );
        @ini_set( 'display_errors', 0 );
    } else {
        if( WP_DEVELOPMENT_MODE ) {
            define( 'WP_DEBUG_DISPLAY', true );
            @ini_set( 'display_errors', 1 );
        } else {
            define( 'WP_DEBUG_DISPLAY', false );
            @ini_set( 'display_errors', 0 );
        }
    }
} else {
    define ('JETPACK_DEV_DEBUG', false );
    @ini_set( 'display_errors', 0 );
    define( 'WP_DEBUG_DISPLAY', false );
    define( 'WP_DEBUG_LOG', false );
    define( 'SCRIPT_DEBUG', false );
}

php WP调试<br/> <br/>将其插入wp-config.php以启用更多样化的WordPress调试

WP调试<br/> <br/>将其插入wp-config.php以启用更多样化的WordPress调试

wp-config-debug.php
<?php

define( 'WP_DEBUG', false );
define( 'WP_DEVELOPMENT_MODE', false );

if ( WP_DEBUG ) {
    define ('JETPACK_DEV_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'SCRIPT_DEBUG', true );

    if ( defined( 'DOING_AJAX' ) && DOING_AJAX || defined( 'DOING_CRON' ) && DOING_CRON ) {
        define( 'WP_DEBUG_DISPLAY', false );
        @ini_set( 'display_errors', 0 );
    } else {
        if( WP_DEVELOPMENT_MODE ) {
            define( 'WP_DEBUG_DISPLAY', true );
            @ini_set( 'display_errors', 1 );
        } else {
            define( 'WP_DEBUG_DISPLAY', false );
            @ini_set( 'display_errors', 0 );
        }
    }
} else {
    define ('JETPACK_DEV_DEBUG', false );
    @ini_set( 'display_errors', 0 );
    define( 'WP_DEBUG_DISPLAY', false );
    define( 'WP_DEBUG_LOG', false );
    define( 'SCRIPT_DEBUG', false );
}

php WP调试<br/> <br/>将其插入wp-config.php以启用更多样化的WordPress调试

WP调试<br/> <br/>将其插入wp-config.php以启用更多样化的WordPress调试

wp-config-debug.php
<?php

define( 'WP_DEBUG', false );
define( 'WP_DEVELOPMENT_MODE', false );

if ( WP_DEBUG ) {
    define ('JETPACK_DEV_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'SCRIPT_DEBUG', true );

    if ( defined( 'DOING_AJAX' ) && DOING_AJAX || defined( 'DOING_CRON' ) && DOING_CRON ) {
        define( 'WP_DEBUG_DISPLAY', false );
        @ini_set( 'display_errors', 0 );
    } else {
        if( WP_DEVELOPMENT_MODE ) {
            define( 'WP_DEBUG_DISPLAY', true );
            @ini_set( 'display_errors', 1 );
        } else {
            define( 'WP_DEBUG_DISPLAY', false );
            @ini_set( 'display_errors', 0 );
        }
    }
} else {
    define ('JETPACK_DEV_DEBUG', false );
    @ini_set( 'display_errors', 0 );
    define( 'WP_DEBUG_DISPLAY', false );
    define( 'WP_DEBUG_LOG', false );
    define( 'SCRIPT_DEBUG', false );
}

php Enfold - 加载自定义avia.js

Enfold - 加载自定义avia.js

custom-avia-js.php
<?php 
if(!is_admin()) add_action('wp_enqueue_scripts', 'avia_register_child_frontend_scripts', 100);
function avia_register_child_frontend_scripts()
{
	$child_theme_url = get_stylesheet_directory_uri();
	wp_dequeue_script('avia-default');

	//register js
	wp_register_script( 'avia-default-child', $child_theme_url.'/js/avia.js', array('jquery'), 1, true);
	wp_enqueue_script( 'avia-default-child' );
}

php Enfold - 加载自定义avia.js

Enfold - 加载自定义avia.js

custom-avia-js.php
<?php 
if(!is_admin()) add_action('wp_enqueue_scripts', 'avia_register_child_frontend_scripts', 100);
function avia_register_child_frontend_scripts()
{
	$child_theme_url = get_stylesheet_directory_uri();
	wp_dequeue_script('avia-default');

	//register js
	wp_register_script( 'avia-default-child', $child_theme_url.'/js/avia.js', array('jquery'), 1, true);
	wp_enqueue_script( 'avia-default-child' );
}

php Enfold - 添加自定义查询

Enfold - 添加自定义查询

enfold-custom-query-sort-by.php
<?php

/*
	 * Yan&Co Modifications - Add Custom Queries
	 *
	 */
	if(!function_exists('avia_custom_query_extension'))
	{
	    function avia_custom_query_extension($query, $params)
	    {
	        global $avia_config;
	        if(!empty($avia_config['avia_custom_query_options']['order']))
	        {
	            $query['order'] = $avia_config['avia_custom_query_options']['order'];
	        }

	        if(!empty($avia_config['avia_custom_query_options']['orderby']))
	        {
	        	if($avia_config['avia_custom_query_options']['orderby'] == 'meta_value_evcal_srow') {
        			
        			// Get today as Unix Timestamp
					$_currentdate_unixtimestamp = strtotime( date('d-m-Y') );

	        		$query['orderby'] = 'meta_value';
	        		$query['meta_key'] = 'evcal_srow';
	        		$query['post_count'] = 3;
	        		/*$query['meta_query'] = array( array(
	        			'key' => 'evcal_srow',
	        			'compare' => 'LIKE',
					) );*/
					
					// Get all events greater or equals to todays unixtimestamp
					$query['meta_query'] = array(
				        array(
				            'key' => 'evcal_srow'
				        ),
				        array(
				        	'key' => 'evcal_srow',
				            'value' => $_currentdate_unixtimestamp,
				            'compare' => '>='
				        )
				    );

				
					


	        	} else {
	        		$query['orderby'] = $avia_config['avia_custom_query_options']['orderby'];	
	        	}
	            
	        }

	        unset($avia_config['avia_custom_query_options']);

	        return $query;
	    }

	    add_filter('avia_masonry_entries_query', 'avia_custom_query_extension', 10, 2);
	    add_filter('avia_post_grid_query', 'avia_custom_query_extension', 10, 2);
	    add_filter('avia_post_slide_query', 'avia_custom_query_extension', 10, 2);
	    add_filter('avia_blog_post_query', 'avia_custom_query_extension', 10, 2);
	    add_filter('avf_magazine_entries_query', 'avia_custom_query_extension', 10, 2);

	    add_filter('avf_template_builder_shortcode_elements','avia_custom_query_options', 10, 1);
	    function avia_custom_query_options($elements)
	    {
	        $allowed_elements = array('av_blog','av_masonry_entries','av_postslider','av_portfolio','av_magazine');

	        if(isset($_POST['params']['allowed']) && in_array($_POST['params']['allowed'], $allowed_elements))
	        {
	            $elements[] = array(
	                "name" => __("Custom Query Orderby",'avia_framework' ),
	                "desc" => __("Set a custom query orderby value",'avia_framework' ),
	                "id"   => "orderby",
	                "type" 	=> "select",
	                "std" 	=> "",
	                "subtype" => array(
	                    __('Default Order',  'avia_framework' ) =>'',
	                    __('Title',  'avia_framework' ) =>'title',
	                    __('Random',  'avia_framework' ) =>'rand',
	                    __('Date',  'avia_framework' ) =>'date',
	                    __('Meta: evcal_srow (Used for Events)', 'avia_framework') =>'meta_value_evcal_srow',
	                    __('Author',  'avia_framework' ) =>'author',
	                    __('Name (Post Slug)',  'avia_framework' ) =>'name',
	                    __('Modified',  'avia_framework' ) =>'modified',
	                    __('Comment Count',  'avia_framework' ) =>'comment_count',
	                    __('Page Order',  'avia_framework' ) =>'menu_order')
	            );

	            $elements[] = array(
	                "name" => __("Custom Query Order",'avia_framework' ),
	                "desc" => __("Set a custom query order",'avia_framework' ),
	                "id"   => "order",
	                "type" 	=> "select",
	                "std" 	=> "",
	                "subtype" => array(
	                    __('Default Order',  'avia_framework' ) =>'',
	                    __('Ascending Order',  'avia_framework' ) =>'ASC',
	                    __('Descending Order',  'avia_framework' ) =>'DESC'));
	        }

	        return $elements;
	    }

	    add_filter('avf_template_builder_shortcode_meta', 'avia_custom_query_add_query_params_to_config', 10, 4);
	    function avia_custom_query_add_query_params_to_config($meta, $atts, $content, $shortcodename)
	    {
	        global $avia_config;
	        if(empty($avia_config['avia_custom_query_options'])) $avia_config['avia_custom_query_options'] = array();

	        if(!empty($atts['order']))
	        {
	            $avia_config['avia_custom_query_options']['order'] = $atts['order'];
	        }

	        if(!empty($atts['orderby']))
	        {
	            $avia_config['avia_custom_query_options']['orderby'] = $atts['orderby'];
	        }

	        return $meta;
	    }
	}

php Enfold - 添加自定义查询

Enfold - 添加自定义查询

enfold-custom-query-sort-by.php
<?php

/*
	 * Yan&Co Modifications - Add Custom Queries
	 *
	 */
	if(!function_exists('avia_custom_query_extension'))
	{
	    function avia_custom_query_extension($query, $params)
	    {
	        global $avia_config;
	        if(!empty($avia_config['avia_custom_query_options']['order']))
	        {
	            $query['order'] = $avia_config['avia_custom_query_options']['order'];
	        }

	        if(!empty($avia_config['avia_custom_query_options']['orderby']))
	        {
	        	if($avia_config['avia_custom_query_options']['orderby'] == 'meta_value_evcal_srow') {
        			
        			// Get today as Unix Timestamp
					$_currentdate_unixtimestamp = strtotime( date('d-m-Y') );

	        		$query['orderby'] = 'meta_value';
	        		$query['meta_key'] = 'evcal_srow';
	        		$query['post_count'] = 3;
	        		/*$query['meta_query'] = array( array(
	        			'key' => 'evcal_srow',
	        			'compare' => 'LIKE',
					) );*/
					
					// Get all events greater or equals to todays unixtimestamp
					$query['meta_query'] = array(
				        array(
				            'key' => 'evcal_srow'
				        ),
				        array(
				        	'key' => 'evcal_srow',
				            'value' => $_currentdate_unixtimestamp,
				            'compare' => '>='
				        )
				    );

				
					


	        	} else {
	        		$query['orderby'] = $avia_config['avia_custom_query_options']['orderby'];	
	        	}
	            
	        }

	        unset($avia_config['avia_custom_query_options']);

	        return $query;
	    }

	    add_filter('avia_masonry_entries_query', 'avia_custom_query_extension', 10, 2);
	    add_filter('avia_post_grid_query', 'avia_custom_query_extension', 10, 2);
	    add_filter('avia_post_slide_query', 'avia_custom_query_extension', 10, 2);
	    add_filter('avia_blog_post_query', 'avia_custom_query_extension', 10, 2);
	    add_filter('avf_magazine_entries_query', 'avia_custom_query_extension', 10, 2);

	    add_filter('avf_template_builder_shortcode_elements','avia_custom_query_options', 10, 1);
	    function avia_custom_query_options($elements)
	    {
	        $allowed_elements = array('av_blog','av_masonry_entries','av_postslider','av_portfolio','av_magazine');

	        if(isset($_POST['params']['allowed']) && in_array($_POST['params']['allowed'], $allowed_elements))
	        {
	            $elements[] = array(
	                "name" => __("Custom Query Orderby",'avia_framework' ),
	                "desc" => __("Set a custom query orderby value",'avia_framework' ),
	                "id"   => "orderby",
	                "type" 	=> "select",
	                "std" 	=> "",
	                "subtype" => array(
	                    __('Default Order',  'avia_framework' ) =>'',
	                    __('Title',  'avia_framework' ) =>'title',
	                    __('Random',  'avia_framework' ) =>'rand',
	                    __('Date',  'avia_framework' ) =>'date',
	                    __('Meta: evcal_srow (Used for Events)', 'avia_framework') =>'meta_value_evcal_srow',
	                    __('Author',  'avia_framework' ) =>'author',
	                    __('Name (Post Slug)',  'avia_framework' ) =>'name',
	                    __('Modified',  'avia_framework' ) =>'modified',
	                    __('Comment Count',  'avia_framework' ) =>'comment_count',
	                    __('Page Order',  'avia_framework' ) =>'menu_order')
	            );

	            $elements[] = array(
	                "name" => __("Custom Query Order",'avia_framework' ),
	                "desc" => __("Set a custom query order",'avia_framework' ),
	                "id"   => "order",
	                "type" 	=> "select",
	                "std" 	=> "",
	                "subtype" => array(
	                    __('Default Order',  'avia_framework' ) =>'',
	                    __('Ascending Order',  'avia_framework' ) =>'ASC',
	                    __('Descending Order',  'avia_framework' ) =>'DESC'));
	        }

	        return $elements;
	    }

	    add_filter('avf_template_builder_shortcode_meta', 'avia_custom_query_add_query_params_to_config', 10, 4);
	    function avia_custom_query_add_query_params_to_config($meta, $atts, $content, $shortcodename)
	    {
	        global $avia_config;
	        if(empty($avia_config['avia_custom_query_options'])) $avia_config['avia_custom_query_options'] = array();

	        if(!empty($atts['order']))
	        {
	            $avia_config['avia_custom_query_options']['order'] = $atts['order'];
	        }

	        if(!empty($atts['orderby']))
	        {
	            $avia_config['avia_custom_query_options']['orderby'] = $atts['orderby'];
	        }

	        return $meta;
	    }
	}

php 更改存档布局

更改存档布局

avia-archive-layout.php
/**
	 * Modify Archive Pages to Display as Grid View
	 */
	add_filter('avf_blog_style','yanco_avia_change_category_blog_layout', 10, 2); 
	function yanco_avia_change_category_blog_layout($layout, $context) {
		if($context == 'archive') {
			$layout = 'blog-grid';
		}

		if($contect == 'tag') {
			$layout = 'blog-grid';
		}

		return $layout;
	}