disable oembed if url is not my site url.
This commit is contained in:
parent
d9c43fd99f
commit
2152e4d435
@ -1,30 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// enable automatic update
|
// enable automatic update
|
||||||
add_filter( 'auto_update_plugin', '__return_true' );
|
add_filter('auto_update_core', '__return_true');
|
||||||
add_filter( 'auto_update_theme', '__return_true' );
|
add_filter('auto_update_theme', '__return_true');
|
||||||
|
add_filter('auto_update_plugin', '__return_true');
|
||||||
|
add_filter('auto_update_translation', '__return_true');
|
||||||
|
|
||||||
|
// load and overrride style of parent theme
|
||||||
add_action('wp_enqueue_scripts', 'theme_enqueue_styles');
|
add_action('wp_enqueue_scripts', 'niu_theme_enqueue_styles');
|
||||||
function theme_enqueue_styles() {
|
function niu_theme_enqueue_styles()
|
||||||
wp_enqueue_style('parent-style', get_template_directory_uri().'/style.css' );
|
{
|
||||||
|
wp_enqueue_style('parent-style', get_template_directory_uri().'/style.css');
|
||||||
wp_enqueue_style('child-style', get_stylesheet_directory_uri().'/style.css', ['parent-style']);
|
wp_enqueue_style('child-style', get_stylesheet_directory_uri().'/style.css', ['parent-style']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable archive page.
|
// enable archive page.
|
||||||
add_filter( 'register_post_type_args', 'post_has_archive', 10, 2 );
|
add_filter('register_post_type_args', 'niu_post_has_archive', 10, 2);
|
||||||
function post_has_archive($args, $post_type) {
|
function niu_post_has_archive($args, $post_type)
|
||||||
|
{
|
||||||
if ('post' == $post_type) {
|
if ('post' == $post_type) {
|
||||||
$args['rewrite'] = true;
|
$args['rewrite'] = true;
|
||||||
$args['has_archive'] = 'news';
|
$args['has_archive'] = 'news';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add google analytics
|
// add google analytics
|
||||||
add_action('wp_head', 'hook_google_analytics');
|
add_action('wp_head', 'niu_add_google_analytics');
|
||||||
function hook_google_analytics() {
|
function niu_add_google_analytics()
|
||||||
|
{
|
||||||
echo <<<EOF
|
echo <<<EOF
|
||||||
|
|
||||||
<!-- Google Tag Manager -->
|
<!-- Google Tag Manager -->
|
||||||
@ -37,3 +42,14 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disable oembed if url is not my site url
|
||||||
|
add_filter('oembed_request_post_id', 'niu_check_oembed_url', 10, 2);
|
||||||
|
function niu_check_oembed_url($post_id, $url)
|
||||||
|
{
|
||||||
|
if (!preg_match('/^'.preg_quote(get_site_url(), '/').'/', $url)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $post_id;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user