| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' ); |
| 3 |
|
| 4 |
/** |
| 5 |
* Load a custom theme |
| 6 |
* |
| 7 |
* @since 5.0.6 |
| 8 |
*/ |
| 9 |
if (isset($_SERVER['HTTP_REFERER']) && preg_match('#wpappninja_simul4#', $_SERVER['HTTP_REFERER'])) { |
| 10 |
$_GET['wpappninja_simul4'] = "true"; |
| 11 |
} |
| 12 |
|
| 13 |
if (!isset($_GET['wpappninja_read_enhanced']) && (isset($_SERVER['HTTP_X_WPAPPNINJA']) || isset($_COOKIE['HTTP_X_WPAPPNINJA']) || isset($_GET['wpappninja_simul4']) || isset($_GET['is_wppwa'])) && !defined('DOING_WPAPPNINJA_API') && (wpappninja_webview_mode(0) == '4' || isset($_GET['wpappninja_simul4']))) { |
| 14 |
|
| 15 |
|
| 16 |
if (get_wpappninja_option('wpappninja_main_theme', 'WPMobile.App') != "No theme") { |
| 17 |
|
| 18 |
global $wp_stylesheet_path; $wp_stylesheet_path=null; |
| 19 |
global $wp_template_path; $wp_template_path=null; |
| 20 |
|
| 21 |
add_filter('theme_root', 'wpappninja_get_theme_root', 10); |
| 22 |
add_filter('stylesheet_directory_uri', 'wpappninja_get_theme_root_css', 10); |
| 23 |
add_filter('template_directory_uri', 'wpappninja_get_theme_root_css', 10); |
| 24 |
|
| 25 |
|
| 26 |
add_action( 'setup_theme', 'wpappninja_switch_theme' ); |
| 27 |
function wpappninja_switch_theme() { |
| 28 |
add_filter('template', 'wpappninja_get_theme_template'); |
| 29 |
add_filter('option_template', 'wpappninja_get_theme_template'); |
| 30 |
add_filter('stylesheet', 'wpappninja_get_theme_template'); |
| 31 |
add_filter('option_stylesheet', 'wpappninja_get_theme_template'); |
| 32 |
} |
| 33 |
|
| 34 |
//remove_filter ('the_content', 'wptexturize'); |
| 35 |
//add_filter( 'the_content', 'wpappninja_remove_theme_shortcode', PHP_INT_MAX ); |
| 36 |
function wpappninja_remove_theme_shortcode( $content ) { |
| 37 |
$content = preg_replace('/(^|[\r\n\s<>])(\[[\/ÀÁ� |
| 38 |
ÃÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿa-zA-Z0-9\s=\'":\|%,#;\-_\.]+\])([\r\n\s<>]|$)/m', "$1$3", $content); |
| 39 |
return $content; |
| 40 |
} |
| 41 |
|
| 42 |
add_action('after_setup_theme', 'wpappninja_remove_admin_bar'); |
| 43 |
function wpappninja_remove_admin_bar() { |
| 44 |
if (get_wpappninja_option('speed', '0') == "1") { |
| 45 |
show_admin_bar(false); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
function wpappninja_get_theme_root() { |
| 53 |
|
| 54 |
$name = get_wpappninja_option('wpappninja_main_theme', 'WPMobile.App'); |
| 55 |
|
| 56 |
|
| 57 |
$themes = wp_get_themes(array('allowed' => 'site')); |
| 58 |
foreach ($themes as $k => $theme) { |
| 59 |
if ($theme->Name == $name) { |
| 60 |
return WP_CONTENT_DIR . '/themes'; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
return WPAPPNINJA_PATH . 'themes'; |
| 65 |
|
| 66 |
} |
| 67 |
|
| 68 |
function wpappninja_get_theme_root_css() { |
| 69 |
|
| 70 |
$name = get_wpappninja_option('wpappninja_main_theme', 'WPMobile.App'); |
| 71 |
|
| 72 |
|
| 73 |
$themes = wp_get_themes(array('allowed' => 'site')); |
| 74 |
foreach ($themes as $k => $theme) { |
| 75 |
if ($theme->Name == $name) { |
| 76 |
return get_theme_root_uri($name) . '/' . $k; |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
if (get_wpappninja_option('speed', '0') == "1") { |
| 81 |
return WPAPPNINJA_URL . 'themes/wpappninja-full'; |
| 82 |
} |
| 83 |
|
| 84 |
return WPAPPNINJA_URL . 'themes/wpappninja'; |
| 85 |
} |
| 86 |
function wpappninja_get_theme_template() { |
| 87 |
|
| 88 |
$name = get_wpappninja_option('wpappninja_main_theme', 'WPMobile.App'); |
| 89 |
|
| 90 |
|
| 91 |
$themes = wp_get_themes(array('allowed' => 'site')); |
| 92 |
foreach ($themes as $k => $theme) { |
| 93 |
if ($theme->Name == $name) { |
| 94 |
return $k; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
if (get_wpappninja_option('speed', '0') == "1") { |
| 99 |
return 'wpappninja-full'; |
| 100 |
} |
| 101 |
|
| 102 |
return 'wpappninja'; |
| 103 |
} |
| 104 |
|
| 105 |
if (get_wpappninja_option('wpappninja_main_theme', 'WPMobile.App') != 'WPMobile.App' && isset($_GET['wpappninja_read_push'])) { |
| 106 |
|
| 107 |
remove_action('template_redirect', 'redirect_canonical'); |
| 108 |
add_filter( 'the_title', '__return_false' ); |
| 109 |
add_filter( 'the_content', 'wpappninja_show_push', PHP_INT_MAX ); |
| 110 |
} |
| 111 |
|