ThemeShaper Forums » Thematic

[closed]

Functions.php question

(6 posts)
  • Started 3 years ago by rscamero92
  • Latest reply from rscamero92
  • This topic is not resolved
  1. I downloaded a small plugin (Style Box). Well I want to add this as a function to my functions.php instead of using it as a plugin. Basically so I can customize it to my liking.

    Here is the plugins functions code....

    //
    //
    //
    function style_box(){
    $style_box = get_option('style_box');
    if($style_box=='1'){
    if ( !defined('WP_CONTENT_URL') ) define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
    $plugin_url = WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__));
    echo '<link rel="stylesheet" href="'.$plugin_url.'/style.css"'.' type="text/css" media="screen" />';
    }
    }

    function active_style_box(){
    add_option('style_box','1','active the plugin');
    }

    function deactive_style_box(){
    delete_option('style_box');
    }

    add_action('wp_head', 'style_box');

    register_activation_hook(__FILE__,'active_style_box');
    register_deactivation_hook(__FILE__,'deactive_style_box');

    What part of the code, if any, do I delete so that it isn't a "plugin". Or am I just over thinking this?

    Posted 3 years ago #
  2. in the past when i wanted to inlude a plugin in my theme, all i did was add

    define('CHILDTHEME_DIRECTORY', get_stylesheet_directory() . '/');
    require_once(CHILDTHEME_DIRECTORY . 'functions/class_post_image_mod.php');

    and that seemed to work. related to your code you will definitely have to change the paths to the stylesheet. i don't know what else. is that all of the code?

    Posted 3 years ago #
  3. Yep that's it. It being such a small function is the reason I just want to include in my functions.php instead of downloading it. I won't be using the images that are included with the plugin so no need to waste the disk space.

    I will try your above code and let ya know if it works.

    Posted 3 years ago #
  4. Well there is CSS codes for it, but nothing out of the norm.

    Posted 3 years ago #
  5. Something doesn't look right to me for some reason, even though it seems to be working fine.

    function style_box(){
    $style_box = get_option('style_box');
    if($style_box=='1'){
    if ( !defined('WP_CONTENT_URL') ) define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
    echo '(link rel="stylesheet" href="wp-content/themes/child/style.css"'.' type="text/css" media="screen" />';
    define('CHILDTHEME_DIRECTORY', get_stylesheet_directory() . '/');
    require_once(CHILDTHEME_DIRECTORY . 'functions/class_post_image_mod.php');
    }
    }

    function active_style_box(){
    add_option('style_box','1','active the plugin');
    }

    function deactive_style_box(){
    delete_option('style_box');
    }

    add_action('wp_head', 'style_box');

    register_activation_hook(__FILE__,'active_style_box');
    register_deactivation_hook(__FILE__,'deactive_style_box');

    Posted 3 years ago #
  6. Well it is working in dreamweaver. But once I save and check it on the test site (localhost) I get the "white screen of death".

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.