/**
* Zorelix functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Zorelix
*
* @author Fiq Hidayat (https://www.fiqhidayat.com)
*/
if (!function_exists('__debug')) :
function __debug()
{
$bt = debug_backtrace();
$caller = array_shift($bt);
echo '
';
print_r([
"file" => $caller["file"],
"line" => $caller["line"],
"args" => func_get_args()
]);
echo '
';
}
endif;
define('ZORELIX_SERVER', 'https://zerolix.com/');
define('ZORELIX_PATH', get_template_directory());
define('ZORELIX_URL', get_template_directory_uri());
/**
* onclick update
* @var [type]
*/
require 'update-checker/plugin-update-checker.php';
$zerolixUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://bitbucket.org/juprimaulana/zerolix',
__FILE__,
'zerolix'
);
//Optional: If you're using a private repository, create an OAuth consumer
//and set the authentication credentials like this:
//Note: For now you need to check "This is a private consumer" when
//creating the consumer to work around #134:
// https://github.com/YahnisElsts/plugin-update-checker/issues/134
$zerolixUpdateChecker->setAuthentication(array(
'consumer_key' => 'uQfZWEF7tzWggNFCuW',
'consumer_secret' => 'xzH8vMbpAxCByrjK4EpsA6XQseCDTUvQ',
));
if (!function_exists('zorelix_setup')) {
/**
* Sets up theme defaults and registers support for various WordPress features.
*/
function zorelix_setup()
{
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
*/
load_theme_textdomain('zorelix', ZORELIX_PATH . '/languages');
// Add default posts and comments RSS feed links to head.
add_theme_support('automatic-feed-links');
/*
* Let WordPress manage the document title.
*/
add_theme_support('title-tag');
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support('post-thumbnails');
// This theme uses wp_nav_menu() in two location.
register_nav_menus(array(
'header' => esc_html__('Header', 'zorelix'),
'footer' => esc_html__('Footer', 'zorelix')
));
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support('html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
));
// Add theme support for selective refresh for widgets.
add_theme_support('customize-selective-refresh-widgets');
}
}
add_action('after_setup_theme', 'zorelix_setup');
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function zorelix_widgets_init()
{
register_sidebar(array(
'name' => esc_html__('Sidebar', 'zorelix'),
'id' => 'sidebar-1',
'description' => esc_html__('Add widgets here.', 'zorelix'),
'before_widget' => '',
'before_title' => '',
));
}
add_action('widgets_init', 'zorelix_widgets_init');
/**
* Enqueue scripts and styles.
*/
function zorelix_scripts()
{
//wp_enqueue_style( 'zorelix', get_stylesheet_uri(), array(), strtotime('now'), 'all' );
if (get_post_meta(get_the_ID(), '_elementor_edit_mode', true)) :
wp_enqueue_script('jquery');
wp_enqueue_script('wp-embed');
else :
wp_dequeue_script('jquery');
wp_dequeue_script('wp-embed');
endif;
//wp_enqueue_script( 'zorelix-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
}
add_action('wp_enqueue_scripts', 'zorelix_scripts');
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require ZORELIX_PATH . '/inc/template-functions.php';
/**
* Customizer additions.
*/
require ZORELIX_PATH . '/inc/customizer-library/customizer-library.php';
require ZORELIX_PATH . '/inc/customizer.php';
/**
* custom metabox
* @var [type]
*/
require ZORELIX_PATH . '/inc/cmb2/init.php';
require ZORELIX_PATH . '/inc/cmb2-conditionals/cmb2-conditionals.php';
require ZORELIX_PATH . '/inc/metabox.php';
if (did_action('elementor/loaded')) {
require ZORELIX_PATH . '/inc/elementor.php';
}
require ZORELIX_PATH . '/inc/license.php';
/**
* Load Jetpack compatibility file.
*/
if (defined('JETPACK__VERSION')) {
require ZORELIX_PATH . '/inc/jetpack.php';
}
remove_action('wp_head', 'feed_links_extra', 3); // Display the links to the extra feeds such as category feeds
remove_action('wp_head', 'feed_links', 2); // Display the links to the general feeds: Post and Comment Feed
remove_action('wp_head', 'rsd_link'); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action('wp_head', 'wlwmanifest_link'); // Display the link to the Windows Live Writer manifest file.
remove_action('wp_head', 'index_rel_link'); // Index link
remove_action('wp_head', 'parent_post_rel_link', 10, 0); // Prev link
remove_action('wp_head', 'start_post_rel_link', 10, 0); // Start link
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // Display relational links for the posts adjacent to the current post.
remove_action('wp_head', 'wp_generator'); // Display the XHTML generator that is generated on the wp_head hook, WP version
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
remove_action('wp_head', 'rel_canonical');
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_action('wp_head', 'rest_output_link_wp_head', 10);
// Disable oEmbed Discovery Links
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
// Disable REST API link in HTTP headers
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
add_filter('show_admin_bar', '__return_false');
//add_action('wp', 'ttt');
function ttt()
{
__debug(get_youtube_id('https://www.youtube.com/watch?v=dT3QMD1wKqw'));
exit;
}
function get_youtube_id($url)
{
$pattern =
'%^# Match any youtube URL
(?:https?://)? # Optional scheme. Either http or https
(?:www\.)? # Optional www subdomain
(?: # Group host alternatives
youtu\.be/ # Either youtu.be,
| youtube\.com # or youtube.com
(?: # Group path alternatives
/embed/ # Either /embed/
| /v/ # or /v/
| /watch\?v= # or /watch\?v=
) # End path alternatives.
) # End host alternatives.
([\w-]{10,12}) # Allow 10-12 for 11 char youtube id.
$%x';
$result = preg_match($pattern, $url, $matches);
if (false !== $result && isset($matches[1])) {
return $matches[1];
}
return false;
}
XML-RPC server accepts POST requests only.