File manager - Edit - /home/vblioqus/y999-game.pro/wp-content/themes/infopediya/functions.php
Back
<?php /** * APK Store Pro functions and definitions * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package APK_Store_Pro */ if ( ! function_exists( 'apk_store_pro_setup' ) ) : /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. */ function apk_store_pro_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on APK Store Pro, use a find and replace * to change 'apk-store-pro' to the name of your theme in all the template files. */ load_theme_textdomain( 'apk-store-pro', get_template_directory() . '/languages' ); // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded <title> tag in the document head, and expect WordPress to * provide it for us. */ 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' ); // Add support for custom logo. add_theme_support( 'custom-logo', array( 'height' => 100, 'width' => 400, 'flex-height' => true, 'flex-width' => true, 'header-text' => array( 'site-title', 'site-description' ), ) ); /* * 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', ) ); // Register navigation menus. register_nav_menus( array( 'primary' => esc_html__( 'Primary Menu', 'apk-store-pro' ), 'footer' => esc_html__( 'Footer Menu', 'apk-store-pro' ), ) ); } endif; add_action( 'after_setup_theme', 'apk_store_pro_setup' ); /** * Enqueue scripts and styles. */ function apk_store_pro_scripts() { // Enqueue the main stylesheet. wp_enqueue_style( 'apk-store-pro-style', get_stylesheet_uri(), array(), '1.0.0' ); // Enqueue Google Fonts (Inter). wp_enqueue_style( 'google-fonts-inter', 'https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap', array(), null ); // Enqueue the main JavaScript file. // Ensure you create an empty 'main.js' file in a 'js' folder inside your theme directory. wp_enqueue_script( 'apk-store-pro-script', get_template_directory_uri() . '/js/main.js', array( 'jquery' ), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'apk_store_pro_scripts' ); /** * Register Custom Post Type for 'Apps'. */ function apk_store_pro_create_app_post_type() { $labels = array( 'name' => _x( 'Apps', 'Post Type General Name', 'apk-store-pro' ), 'singular_name' => _x( 'App', 'Post Type Singular Name', 'apk-store-pro' ), 'menu_name' => __( 'Apps', 'apk-store-pro' ), 'name_admin_bar' => __( 'App', 'apk-store-pro' ), 'archives' => __( 'App Archives', 'apk-store-pro' ), 'attributes' => __( 'App Attributes', 'apk-store-pro' ), 'parent_item_colon' => __( 'Parent App:', 'apk-store-pro' ), 'all_items' => __( 'All Apps', 'apk-store-pro' ), 'add_new_item' => __( 'Add New App', 'apk-store-pro' ), 'add_new' => __( 'Add New', 'apk-store-pro' ), 'new_item' => __( 'New App', 'apk-store-pro' ), 'edit_item' => __( 'Edit App', 'apk-store-pro' ), 'update_item' => __( 'Update App', 'apk-store-pro' ), 'view_item' => __( 'View App', 'apk-store-pro' ), 'view_items' => __( 'View Apps', 'apk-store-pro' ), 'search_items' => __( 'Search App', 'apk-store-pro' ), 'not_found' => __( 'Not found', 'apk-store-pro' ), 'not_found_in_trash' => __( 'Not found in Trash', 'apk-store-pro' ), 'featured_image' => __( 'App Screenshot', 'apk-store-pro' ), 'set_featured_image' => __( 'Set app screenshot', 'apk-store-pro' ), 'remove_featured_image' => __( 'Remove app screenshot', 'apk-store-pro' ), 'use_featured_image' => __( 'Use as app screenshot', 'apk-store-pro' ), 'insert_into_item' => __( 'Insert into app', 'apk-store-pro' ), 'uploaded_to_this_item' => __( 'Uploaded to this app', 'apk-store-pro' ), 'items_list' => __( 'Apps list', 'apk-store-pro' ), 'items_list_navigation' => __( 'Apps list navigation', 'apk-store-pro' ), 'filter_items_list' => __( 'Filter apps list', 'apk-store-pro' ), ); $args = array( 'label' => __( 'App', 'apk-store-pro' ), 'description' => __( 'Custom post type for Android applications.', 'apk-store-pro' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-smartphone', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'rewrite' => array( 'slug' => 'apps' ), 'capability_type' => 'post', 'show_in_rest' => true, // Enable for Gutenberg and REST API ); register_post_type( 'app', $args ); } add_action( 'init', 'apk_store_pro_create_app_post_type', 0 ); /** * Register Custom Taxonomy for 'App Categories'. */ function apk_store_pro_create_app_taxonomies() { $labels = array( 'name' => _x( 'App Categories', 'Taxonomy General Name', 'apk-store-pro' ), 'singular_name' => _x( 'App Category', 'Taxonomy Singular Name', 'apk-store-pro' ), 'menu_name' => __( 'App Categories', 'apk-store-pro' ), 'all_items' => __( 'All App Categories', 'apk-store-pro' ), 'parent_item' => __( 'Parent App Category', 'apk-store-pro' ), 'parent_item_colon' => __( 'Parent App Category:', 'apk-store-pro' ), 'new_item_name' => __( 'New App Category Name', 'apk-store-pro' ), 'add_new_item' => __( 'Add New App Category', 'apk-store-pro' ), 'edit_item' => __( 'Edit App Category', 'apk-store-pro' ), 'update_item' => __( 'Update App Category', 'apk-store-pro' ), 'view_item' => __( 'View App Category', 'apk-store-pro' ), 'separate_items_with_commas' => __( 'Separate app categories with commas', 'apk-store-pro' ), 'add_or_remove_items' => __( 'Add or remove app categories', 'apk-store-pro' ), 'choose_from_most_used' => __( 'Choose from the most used', 'apk-store-pro' ), 'popular_items' => __( 'Popular App Categories', 'apk-store-pro' ), 'search_items' => __( 'Search App Categories', 'apk-store-pro' ), 'not_found' => __( 'Not Found', 'apk-store-pro' ), 'no_terms' => __( 'No app categories', 'apk-store-pro' ), 'items_list' => __( 'App Categories list', 'apk-store-pro' ), 'items_list_navigation' => __( 'App Categories list navigation', 'apk-store-pro' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true, 'rewrite' => array( 'slug' => 'app-category' ), 'show_in_rest' => true, // Enable for Gutenberg and REST API ); register_taxonomy( 'app_category', array( 'app' ), $args ); } add_action( 'init', 'apk_store_pro_create_app_taxonomies', 0 ); /** * Add custom meta boxes for 'App' post type. */ function apk_store_pro_add_app_meta_boxes() { add_meta_box( 'app_details', // Unique ID esc_html__( 'App Details', 'apk-store-pro' ), // Box title 'apk_store_pro_app_details_callback', // Callback function to render the box 'app', // Post type where the box will be shown 'normal', // Context (e.g., 'normal', 'side', 'advanced') 'high' // Priority (e.g., 'high', 'low') ); } add_action( 'add_meta_boxes', 'apk_store_pro_add_app_meta_boxes' ); /** * Render the App Details meta box. * * @param WP_Post $post The current post object. */ function apk_store_pro_app_details_callback( $post ) { // Add a nonce field for security. wp_nonce_field( 'save_app_details', 'app_details_nonce' ); // Get existing meta values. $version = get_post_meta( $post->ID, 'app_version', true ); $rating = get_post_meta( $post->ID, 'app_rating', true ); $downloads = get_post_meta( $post->ID, 'app_downloads', true ); $size = get_post_meta( $post->ID, 'app_size', true ); $download_url = get_post_meta( $post->ID, 'app_download_url', true ); $icon = get_post_meta( $post->ID, 'app_icon', true ); $featured = get_post_meta( $post->ID, 'featured', true ); ?> <table class="form-table"> <tr> <th><label for="app_version"><?php esc_html_e( 'Version:', 'apk-store-pro' ); ?></label></th> <td><input type="text" id="app_version" name="app_version" value="<?php echo esc_attr( $version ); ?>" class="regular-text" /></td> </tr> <tr> <th><label for="app_rating"><?php esc_html_e( 'Rating (0-5):', 'apk-store-pro' ); ?></label></th> <td><input type="number" id="app_rating" name="app_rating" value="<?php echo esc_attr( $rating ); ?>" step="0.1" min="0" max="5" class="small-text" /></td> </tr> <tr> <th><label for="app_downloads"><?php esc_html_e( 'Downloads (e.g., 1M+):', 'apk-store-pro' ); ?></label></th> <td><input type="text" id="app_downloads" name="app_downloads" value="<?php echo esc_attr( $downloads ); ?>" class="regular-text" /></td> </tr> <tr> <th><label for="app_size"><?php esc_html_e( 'Size (e.g., 50MB):', 'apk-store-pro' ); ?></label></th> <td><input type="text" id="app_size" name="app_size" value="<?php echo esc_attr( $size ); ?>" class="regular-text" /></td> </tr> <tr> <th><label for="app_download_url"><?php esc_html_e( 'Download URL:', 'apk-store-pro' ); ?></label></th> <td><input type="url" id="app_download_url" name="app_download_url" value="<?php echo esc_attr( $download_url ); ?>" class="large-text" style="width: 100%;" /></td> </tr> <tr> <th><label for="app_icon"><?php esc_html_e( 'Icon (Emoji or URL):', 'apk-store-pro' ); ?></label></th> <td><input type="text" id="app_icon" name="app_icon" value="<?php echo esc_attr( $icon ); ?>" placeholder="📱" class="regular-text" /> <p class="description"><?php esc_html_e( 'Enter an emoji (e.g., 🎮) or a URL to an image icon.', 'apk-store-pro' ); ?></p></td> </tr> <tr> <th><label for="featured"><?php esc_html_e( 'Featured App:', 'apk-store-pro' ); ?></label></th> <td><input type="checkbox" id="featured" name="featured" value="yes" <?php checked( $featured, 'yes' ); ?> /> <label for="featured"><?php esc_html_e( 'Mark as featured', 'apk-store-pro' ); ?></label></td> </tr> </table> <?php } /** * Save app meta data when the post is saved. * * @param int $post_id The ID of the post being saved. */ function apk_store_pro_save_app_details( $post_id ) { // Check if our nonce is set and verified. if ( ! isset( $_POST['app_details_nonce'] ) || ! wp_verify_nonce( $_POST['app_details_nonce'], 'save_app_details' ) ) { return; } // If this is an autosave, our form has not been submitted, so we don't want to do anything. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Check the user's permissions. if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } // Define the fields to save. $fields = array( 'app_version', 'app_rating', 'app_downloads', 'app_size', 'app_download_url', 'app_icon' ); foreach ( $fields as $field ) { if ( isset( $_POST[ $field ] ) ) { update_post_meta( $post_id, $field, sanitize_text_field( $_POST[ $field ] ) ); } else { delete_post_meta( $post_id, $field ); // Delete if checkbox/field is empty } } // Handle the 'featured' checkbox separately. $featured = isset( $_POST['featured'] ) ? 'yes' : 'no'; update_post_meta( $post_id, 'featured', $featured ); } add_action( 'save_post', 'apk_store_pro_save_app_details' ); /** * Customize excerpt length. * * @param int $length The default excerpt length. * @return int The new excerpt length. */ function apk_store_pro_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'apk_store_pro_excerpt_length', 999 ); // Use a high priority to ensure it overrides others /** * Modify search query to only search 'app' post type by default. * * @param WP_Query $query The current WP_Query object. */ function apk_store_pro_search_apps_only( $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { // If no post type is explicitly set, set it to 'app'. // This allows other post types to be searched if a specific post_type param is added. if ( empty( $query->get( 'post_type' ) ) ) { $query->set( 'post_type', array( 'post', 'page', 'app' ) ); // Include default post types and 'app' } } } add_action( 'pre_get_posts', 'apk_store_pro_search_apps_only' ); /** * Fallback menu for when no primary menu is set. */ function apk_store_pro_default_menu() { echo '<ul>'; echo '<li><a href="' . esc_url( home_url( '/' ) ) . '">' . esc_html__( 'Home', 'apk-store-pro' ) . '</a></li>'; echo '<li><a href="' . esc_url( get_post_type_archive_link( 'app' ) ) . '">' . esc_html__( 'Apps', 'apk-store-pro' ) . '</a></li>'; // You might want to dynamically list categories here or add a static link to categories page echo '<li><a href="#">' . esc_html__( 'Categories', 'apk-store-pro' ) . '</a></li>'; echo '<li><a href="#">' . esc_html__( 'About', 'apk-store-pro' ) . '</a></li>'; echo '</ul>'; } // Ensure post thumbnails work for app post type add_action( 'after_setup_theme', 'apk_store_enable_thumbnails' ); function apk_store_enable_thumbnails() { add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-thumbnails', array( 'app' ) ); // Add custom image sizes for app icons add_image_size( 'app-icon', 80, 80, true ); add_image_size( 'app-icon-large', 150, 150, true ); } // Ensure post thumbnails work properly add_action( 'after_setup_theme', 'apk_store_fix_thumbnails' ); function apk_store_fix_thumbnails() { add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-thumbnails', array( 'app' ) ); } function theme_enqueue_styles() { wp_enqueue_style( 'main-style', get_stylesheet_uri(), array(), filemtime(get_stylesheet_directory() . '/style.css') // Auto-updates version ); } add_action('wp_enqueue_scripts', 'theme_enqueue_styles'); function load_ancola_font() { echo '<link href="https://your-font-source/ancola.css" rel="stylesheet">'; } add_action('wp_head', 'load_ancola_font');
| ver. 1.4 |
Github
|
.
| PHP 8.2.30 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings