HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: /home/mmickelson/theflexguys.com/baronconstruct/wp-content/themes/dark-wood/functions.php
<?php
/* Removing title attribute from the menu */
/******************************************/

function remove_title_attribute($subject) {
    $result = preg_replace('/title=\"(.*?)\"/','',$subject);
    return $result;
}

/** Theme Options **/
/*******************/

class darkwoodoptions {
    function getoptions() {
        $options = get_option('darkwood_options');
        if (!is_array($options)) {
            $options['sidebar_count'] = '2';
            $options['show_tags'] = true;
            $options['show_cats'] = true;
            $options['show_share'] = true;
            $options['auto_thumb'] = true;
            update_option('darkwood_options', $options);
        }
        return $options;
    }
    
    function addoptions() {
        if(isset($_POST['darkwood_save'])) {
            $options = darkwoodoptions::getoptions();
            if($_POST['sidebar_count'] == '1') {
                $options['sidebar_count'] = '1';
            }
            else {
                $options['sidebar_count'] = '2';
            }
            if($_POST['show_tags']) {
                $options['show_tags'] = (bool)true;
            } else {
                $options['show_tags'] = (bool)false;
            }
            if($_POST['show_cats']) {
                $options['show_cats'] = (bool)true;
            } else {
                $options['show_cats'] = (bool)false;
            }
            if($_POST['show_share']) {
                $options['show_share'] = (bool)true;
            } else {
                $options['show_share'] = (bool)false;
            }
            if($_POST['auto_thumb']) {
                $options['auto_thumb'] = (bool)true;
            } else {
                $options['auto_thumb'] = (bool)false;
            }
            update_option('darkwood_options', $options);
        } else if(isset($_POST['darkwood_reset'])) {
            delete_option('darkwood_options');
        } else {
            darkwoodoptions::getoptions();
        }
        add_theme_page(__('Dark Wood Theme Options', 'dark-wood'), __('Dark Wood Theme Options', 'dark-wood'), 'edit_themes', basename(__FILE__), array('darkwoodoptions', 'displayoptions'));
    }
    
    function displayoptions() {
        $options = darkwoodoptions::getoptions();
    ?>
    <form action="#" method="post" enctype="multipart/form-data" name="darkwood_options_form" id="darkwood_options_form">
        <div class="wrap">
            <h2><?php _e('Dark Wood Theme Options'); ?></h2>
            <?php if(isset($_POST['darkwood_save'])) { ?>
                <div style="background: #FFF299; padding: 5px; border: 1px #FFDE99 solid;"><?php _e('Settings Saved'); ?></div>
            <?php } ?>
            <?php if(isset($_POST['candy_reset'])) { ?>
                <div style="background: #FFF299; padding: 5px; border: 1px #FFDE99 solid;"><?php _e('Default Settings Restored'); ?></div>
            <?php } ?>
            <hr>
            <h3><?php _e('Sidebar Options', 'dark-wood'); ?></h3>
            <p>
                <label><?php _e('Select number of sidebars: ', 'dark-wood'); ?></label>
                <select name="sidebar_count">
                    <option value="1" <?php if($options['sidebar_count'] == "1") { ?> selected="selected" <?php } ?> ><?php _e('1'); ?></option>
                    <option value="2"<?php if($options['sidebar_count'] == "2") { ?> selected="selected" <?php } ?> ><?php _e('2'); ?></option>
                </select>
            </p>
            <hr>
            <h3><?php _e('Post Meta Options','iCandy'); ?></h3>
            <p>
                <label style="width: 200px"><?php _e('Display Tags: '); ?></label>
                <input name="show_tags" type="checkbox" value="checkbox" <?php if($options['show_tags']) echo "checked='checked'"; ?> />
            </p>
            <p>
                <label style="width: 200px"><?php _e('Display Categories: '); ?></label>
                <input name="show_cats" type="checkbox" value="checkbox" <?php if($options['show_cats']) echo "checked='checked'"; ?> />
            </p>
            <p>
                <label style="width: 200px"><?php _e('Display Sharing link: '); ?></label>
                <input name="show_share" type="checkbox" value="checkbox" <?php if($options['show_share']) echo "checked='checked'"; ?> />
            </p>
            <hr>
            <h3><?php _e('Automatic Thumbnail Options','iCandy'); ?></h3>
            <p>
                <label style="width: 200px"><?php _e('Automatically make images on front pages as thumbnails ? '); ?></label>
                <input name="auto_thumb" type="checkbox" value="checkbox" <?php if($options['auto_thumb']) echo "checked='checked'"; ?> />
            </p>
            <p class="submit">
                <input class="button-primary" type="submit" name="darkwood_save" value="<?php _e('Save Changes', 'dark-wood'); ?>" />
                <input class="button-primary" type="submit" name="darkwood_reset" value="<?php _e('Reset to default settings', 'dark-wood'); ?>" />
            </p>
        </div>
    </form>
    <?php
    }
}
add_action('admin_menu', array('darkwoodoptions', 'addoptions'));

/* Registering Sidebars */
/************************/

if ( function_exists('register_sidebars') ) {
    $options = get_option('darkwood_options');
    register_sidebars($options['sidebar_count'],array(
        'name'=>'Sidebar %d',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>'
    ));
}

/* Initialize Options */
/**********************/

function initoptions() {
    $options = get_option('darkwood_options');
    if($options['show_tags'] != true and $options['show_tags'] != false) $options['show_tags'] = true;
    if($options['show_cats'] != true and $options['show_cats'] != false) $options['show_cats'] = true;
    if($options['show_share'] != true and $options['show_share'] != false) $options['show_share'] = true;
    if($options['auto_thumb'] != true and $options['auto_thumb'] != false) $options['auto_thumb'] = true;
    return $options;
}

/* Automatic Post Thumbnail */
/****************************/

function auto_thumbnail($content)
{
    $options = initoptions();
    if(!is_single() and !is_page() and $options['auto_thumb']) {
        $pattern = "<img";
        $replacement = "<img width=\"150\" height=\"150\"";
        $content = str_ireplace($pattern, $replacement, $content);
    }
    return $content;
}
add_filter('the_content','auto_thumbnail');

?>