__( 'Primary Menu', 'badr' ), ) ); } add_action( 'after_setup_theme', 'badr_theme_setup' ); // تحميل ملفات CSS و JavaScript الأساسية function badr_enqueue_scripts() { // تحميل ملف style.css wp_enqueue_style( 'badr-style', get_stylesheet_uri() ); // تحميل ملف JavaScript الرئيسي (إذا كان هناك ملف) // wp_enqueue_script( 'badr-script', get_template_directory_uri() . '/js/main.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'badr_enqueue_scripts' ); // إضافة دعم للشعار المخصص (اختياري) function badr_custom_logo_setup() { $defaults = array( 'height' => 50, 'width' => 50, 'flex-height' => true, 'flex-width' => true, ); add_theme_support( 'custom-logo', $defaults ); } add_action( 'after_setup_theme', 'badr_custom_logo_setup' ); function theme_prefix_setup() { add_theme_support( 'site-icon' ); } add_action( 'after_setup_theme', 'theme_prefix_setup' ); // عنصر مخصص للقوائم (اختياري) function excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'...'; } else { $excerpt = implode(" ",$excerpt); } $excerpt = preg_replace('`[[^]]*]`','',$excerpt); return $excerpt; } function content($limit) { $content = explode(' ', get_the_content(), $limit); if (count($content)>=$limit) { array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); } $content = preg_replace('/[.+]/','', $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return $content; } function get_excerpt(){ $excerpt = get_the_content(); $excerpt = preg_replace(" ([.*?])",'',$excerpt); $excerpt = strip_shortcodes($excerpt); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, 450); $excerpt = substr($excerpt, 0, strripos($excerpt, " ")); $excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt)); $excerpt = $excerpt.'...'; return $excerpt; } function custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); add_action( 'after_setup_theme', 'ja_theme_setup' ); function ja_theme_setup() { add_theme_support( 'post-thumbnails'); } class Theme_Update_Checker { private $theme_slug; private $version; private $update_url; public function __construct($theme_slug, $version, $update_url) { $this->theme_slug = $theme_slug; $this->version = $version; $this->update_url = $update_url; add_filter('pre_set_site_transient_update_themes', array($this, 'check_for_update')); add_filter('themes_api', array($this, 'themes_api_handler'), 10, 3); } public function check_for_update($transient) { if (empty($transient->checked)) { return $transient; } $response = wp_remote_get($this->update_url); if (!is_wp_error($response) && is_array($response)) { $update_data = json_decode($response['body']); if (version_compare($this->version, $update_data->version, '<')) { $transient->response[$this->theme_slug] = array( 'new_version' => $update_data->version, 'url' => $update_data->url, 'package' => $update_data->url ); } } return $transient; } public function themes_api_handler($false, $action, $args) { if ($action === 'theme_information' && $args->slug === $this->theme_slug) { $response = wp_remote_get($this->update_url); if (!is_wp_error($response) && is_array($response)) { $update_data = json_decode($response['body']); return (object) array( 'name' => $this->theme_slug, 'slug' => $this->theme_slug, 'version' => $update_data->version, 'author' => 'Hany Elnaggar', 'author_profile' => 'https://www.hanybee.com', 'homepage' => 'https://www.hanybee.com', 'download_link' => $update_data->url, 'requires' => '5.0', 'tested' => '6.6', 'last_updated' => date('Y-m-d'), 'sections' => array( 'description' => 'Theme description here.', 'changelog' => $update_data->changelog, ) ); } } return $false; } } new Theme_Update_Checker('badr', '1.0.3', 'https://www.hanybee.com/badr-theme/version.json'); ?>