Support » Plugin: Yet Another Photoblog » [Plugin: Yet Another Photoblog] WP_DEBUG = true. Also: code for plugin author. Debug better.

  • 5 updates you should consider doing, referencing code from (latest) version 1.9.32:

    1. load_plugin_textdomain() is using a deprecated argument.
    lib/Yapb.class.php, line 120:
    load_plugin_textdomain('yapb', 'wp-content/plugins/' . YAPB_PLUGINDIR_NAME . '/lang/');

    change to:
    load_plugin_textdomain('yapb', false, YAPB_PLUGINDIR_NAME . '/lang/');

    2. get_settings() has been deprecated. Use get_option()
    lib/Yapb.class.php, line 120:
    if (get_settings('yapb_form_on_page_form')) {

    change to:
    if (get_option('yapb_form_on_page_form')) {

    also, in lib/YapbImage.class.php
    … too many to mention Do a search/replace.

    3. wp_specialchars() is deprecated. Use esc_attr()
    $category->name = wp_specialchars($category->name);

    change to:
    $category->name = esc_attr($category->name);

    4. Use a defined value already available, one that works as you mean it to here.
    lib/includes/Yapbconstants.script.php, line 75-ish (i’ve modded my version, just find this text:)
    define('YAPB_PLUGIN_PATH', get_option('siteurl') . '/wp-content/plugins/' . YAPB_PLUGINDIR_NAME . '/');

    change to:

    5. This is not an easy problem to solve: In lib/includes/Yapbconstants.script.php, line 8 or so, you’re taking a completely wild guess as to where wp-config.php is located. Unfortunately, with the ability for developers to put the wp-content, plugins, and themes directories outside of the WordPress installation directory, you – as the author – can’t really know what that location will be.

    One idea though: I’ve played with writing a function for the plugin activation hook that writes an XML file with the important bits of info in my plugin’s directory; then, I just treat that XML file as a cheap/dirty data source, using SimpleXML to pull out the info i wrote to it, like WP_PLUGIN_DIR, ABS_PATH, WP_PLUGIN_URL, etc.


    register_activation_hook(__FILE__, 'myplugin_register_plugin');
    	function myplugin_register_plugin($server = 'production'){
    		// create our xml object
    		$bootstrap_info = new SimpleXMLElement('<bootstrap_info></bootstrap_info>');
    		// add the WordPress node + path & url
    		$Wordpress = $bootstrap_info->addChild('WordPress');
    		// save it all
    		saveXMLFormatted($bootstrap_info, dirname(__FILE__) . '/bootstrap_info.xml');
    	function saveXMLFormatted( $xml, $filename ){
    		// write data to file
    		// use DOMDocument->saveXML instead of SimpleXML->asXML because we want pretty formatting
    		$doc = new DOMDocument('1.0');
    		$doc->preserveWhiteSpace = false;
    		$doc->loadXML( $xml->asXML());
    		$doc->formatOutput = true;
    		file_put_contents( $filename, $doc->saveXML());
    // bootstrap WordPress
    $bootstrap_info = simplexml_load_file(dirname(__FILE__) . '/bootstrap_info.xml');
    require_once($bootstrap_info->WordPress['abspath'] . '/wp-config.php)

Viewing 5 replies - 1 through 5 (of 5 total)
  • update 6: you’re using a deprecated argument in add_options_page().
    lib/Yapb.class.php, line 564:

    // find this and comment it out:
    // add_options_page('YAPB', 'YAPB', 8, basename(__FILE__), array(&$this, 'render_options_panel_content'));
    // replace it with this:
    add_options_page('YAPB', 'YAPB', 'edit_posts', basename(__FILE__), array(&$this, 'render_options_panel_content'));

    Plugin Author jaroat


    Lots of thanks for your feedback – Sorry i’ve not seen it before. The changes will be implemented in version 1.10.2.

    According to the location of wp-config.php i’ve found the following documentation:

    Seems you can move the wp-config.php only one dir up: Do you know another possibility to move the wp-config.php to another location without hacking the core code? If not, i would only scan the two possible locations and include the file from there.

    Many thanks again for your work and detailed feedback! It’s people like you that help keeping the plugin uptodate, up and running!

    thanks from Salzburg,

    – Johannes

    boy i’m not sure, i believe that those are the only 2 options for wp-config: in the wordpress directory, or one-level up.

    one thing to consider though – maybe the file you really want to be loading is worpdress/wp-load.php, rather than config?

    rock! 🙂

    Plugin Author jaroat


    You’re right: wp-load.php does it and always stays on the same position.

    I’ll take a look around if other doable requests are out there and then release 1.10.2

    thanks again for your help and feedback!

    br from Salzburg,

    – Johannes

    anytime! and thanks for the years of work you’ve done on this plugin 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Yet Another Photoblog] WP_DEBUG = true. Also: code for plugin author. Debug better.’ is closed to new replies.