How to add a date creation field when a custom taxonomy relationship is created?

I need to display a list of posts and order it by date. The date of when the taxonomy term relationship was created. Is this possible? If so, how can I approach it? Thank you. ## EDIT - SOLVED! Thank you to G. M. for helping me out. Here is what I did: For each set and remove action I give it a different meta_key with a user name as variable   * The meta_key with variable              $meta_key = '_category_relation_added_' . $user_name;        * To Remove term and meta              delete_post_meta($post_ID, $meta_key);     wp_remove_object_terms( $post_ID, $user_name, $taxonomy );        * To Add term and meta              wp_set_object_terms( $post_ID, $user_name, $taxonomy, true );     update_post_meta( $post_ID, $meta_key, time() );            * Then we query the posts with WP_Query              $meta_key = '_category_relation_added_' . $user_name;     $args = array(       // all your args here       'meta_key' => $meta_key,       'orderby'  => 'meta_value_num',       'order'    => 'DESC' // from more to less recent     );     $query = new WP_Query( $args );      ## UPDATE - To delete all postmeta related to the term when the term is deleted.               add_action( 'delete_term_taxonomy', function($tt_id) {              $term = get_term_by('term_taxonomy_id', $tt_id, 'favorite');             $user_name = $term->name;         $meta_key = "_category_relation_added_" . $user_name;         delete_post_meta_by_key( $meta_key );          }, 9, 1);


Custom background front page only ? is_front_page() issue?

> **Possible Duplicate:**   >  Custom background for the index page only? I need to get this right. What iam looking for is to change background image from wp-admin , for front page only. I get it work with add_custom_background(); in my functions.php. But that changes goes for the whole page. I ve been told that i should use, if_front_page but i dont get it to work. This is how far ive made it:                 if ( is_front_page() )     {        add_custom_background();     }


load styles and scripts in network admin not working

I am trying to load scripts on three different screens ONLY. I am getting the styles on the `ins-carrier-display` pages but they do not print on the `ins- carrier-edit` page. Am I missing something?               // Create admin page navigation listings     function bf_carrier_admin_network() {       global $bfc_admin_page;       $bfc_admin_page = add_submenu_page('settings.php', 'Carriers', 'BrightFire Carriers', 'edit_posts', 'ins-carrier-edit', 'carrier_admin_network');        }          function bf_carrier_admin_actions() {       global $bfc_admin_page;       if (current_user_can('manage_options')){         $bfc_admin_page = add_options_page('BrightFire Carriers', 'BrightFire Carriers', 'edit_posts', 'ins-carrier-display', 'carrier_admin');          }else{         $bfc_admin_page = add_menu_page('Carriers', 'Carriers', 'edit_posts', 'ins-carrier-display', 'carrier_admin','dashicons-products',58);       }     }          add_action('admin_menu', 'bf_carrier_admin_actions');     add_action('network_admin_menu', 'bf_carrier_admin_network');          //registser admin scripts     add_action('admin_enqueue_scripts', 'bfc_styles_scripts');     function bfc_styles_scripts(){       global $bfc_admin_page;            $bfc_admin_screen = get_current_screen();            if ( $bfc_admin_page == $bfc_admin_screen->id ) {         wp_enqueue_script('jquery');         wp_enqueue_script('jquery-effects-core');         wp_enqueue_script('jquery-effects-drop');         wp_enqueue_script('jquery-effects-highlight');         wp_enqueue_style( 'bfc_admin_style', plugins_url( 'css/admin.css' , __FILE__ ));         wp_enqueue_script('bootstrap', plugins_url('js/bootstrap.js', __FILE__), array('jquery'), '2.3.2');        }     }


Importing Wordpress Posts With Custom Meta Data As CSV Files Through PHPMyAdmin

I have been importing data records as posts with custom meta data directly into Wordpress via the CSV Importer plugin. It works okay, however, there are some issues with it. Issues: 1) It takes countless hours to import massive amounts of records (I have spent dozens of hours importing about 5,000 records, and still have about 150,000 records to go). 2) The plugin isn't supported anymore, so I have no idea of it's stability. My hope is that I can find a way to import these records that are in csv format into phpmyadmin directly. Here is what the posts contain... Post title Post content plus about 8 custom fields (which I make visible through some script that I add to the single-post.php file for my theme). So....does anyone know how to import these posts through phpmyadmin, so that I don't have to rely on a plugin to pull them into wordpress, which **then** inputs them into my mysql database and back into wordpress? I'd rather just import them directly into phpmyadmin which would shoot them directly into mysql, which I would think is the more intelligent and effective way to do things anyhow. Thanks in advance for anyone's input on this. I am much appreciative.


PHP Warning: preg_match() expects & PHP Warning: strip_tags()

I got this error log, do you know what is this and how can i fix this?               [31-Jan-2013 22:01:25 UTC] PHP Warning:  preg_match() expects parameter 2 to be string, array given in /home/xxx/public_html/wp-includes/formatting.php on line 608     [31-Jan-2013 22:01:25 UTC] PHP Warning:  strip_tags() expects parameter 1 to be string, array given in /home/xxx/public_html/wp-includes/formatting.php on line 968


Different markup for second page

I'm pulling posts via ajax and I want to know how to get different html for the second page of posts.

                 <?php thing I want on the first page but not the second ?>
                       <?php if (have_posts()) : ?>                            <?php while ( have_posts() ) : the_post() ?>                                <?php if ( has_post_format( 'quote' )) {                          get_template_part( 'quote-post' );                     } elseif ( has_post_format( 'video' )) {                         get_template_part( 'video-post' );                     }elseif ( has_post_format( 'image' )) {                         get_template_part( 'image-post' );                     } else {                        get_template_part( 'standard-post' );                     }                      ?>                            <?php endwhile;?>                  <?php endif; ?>

       Problem is it's displaying the div profile-holder on all subsequent pages.


Wordpress multi user registration sites

For one of our customers we are currently creating a (mobile) news app which include the blogs of their WP multisite. We made an REST connection between the DB but are stuck at the following problem: We like to register people to the WP_user table but we have to give them access to 9 sites in total. Is it possible to dump all users in 1 pool to grant access to post comments on all sites? Thanks in advance,


Minimum Template Files for Theme Development

WordPress has minimum theme template files as   * style.css    * index.php and also some other files as listed here. If the theme developer wants to build theme with less bells and whistles, what are some of the template files which should be included at minimum? There isn't any guidelines in the WordPress docex. Only thing that you can find is what files and when to include them. For making use of most of the wordpress functions without any conflict, there doesn't seem to be specific number mentioned for number of template files. So how many files should be there when you build a theme from say raw html template?


Update field in database for users

I have made a frontend form for the admins where they can check a checkbox for each user and submit the form data by post. For all the users that are checked, a value should be changed in a field in the database. The slug for this field could be `payment_status`. What is a method to update or change the value of a field in the database for **a specific user**? I have looked at a question like this: Update some database fields when post is saved And have been trying with the options methods in wordpress. But I have trouble finding the way to change the value for the specific user. When this is possible for me, it might not be difficult to convert this into repeating the update process for every checked user in the post data.


Order a query by meta_value and then by post_date

I'm using the following query (mytheme/function.php) to sort posts by Custom Field(=admin_rate)               function sort_searchresult_by_admin_rate($k) {     if (!is_home()) {     $k->query_vars['meta_key'] = 'admin_rate';     $k->query_vars['orderby'] = 'meta_value';     $k->query_vars['order'] = 'DESC';     }     }     add_action('pre_get_posts','sort_searchresult_by_admin_rate');      For example I have 4 posts:               Title1  admin_rate=3    post_date=25 February 2014     Title2  admin_rate=4    post_date=26 February 2014     Title3  admin_rate=1    post_date=27 February 2014     Title4  admin_rate=1    post_date=28 February 2014      with sort_searchresult_by_admin_rate($k), I get the following results:               Title2  admin_rate=4    post_date=26 February 2014 (GOOD!)     Title1  admin_rate=3    post_date=25 February 2014 (GOOD!)     Title3  admin_rate=1    post_date=27 February 2014 (BAD!)     Title4  admin_rate=1    post_date=28 February 2014 (BAD!)      I want to Order posts by meta_value and then by date DESC same as:               Title2  admin_rate=4    post_date=26 February 2014 (GOOD!)     Title1  admin_rate=3    post_date=25 February 2014 (GOOD!)     Title4  admin_rate=1    post_date=28 February 2014 (GOOD!)     Title3  admin_rate=1    post_date=27 February 2014 (GOOD!)      is there a way? thanks.


wp_nav_menu_items - mobile problem

I'm using the wp_nav_menu_items filter hook to add a subnav to the main navigation. It uses a child theme for 2013               function new_nav_menu_items($items) {         global $wpdb;               $localities_links = '';              $query = //etc         $localities = //etc              if( $localities ) {                   foreach( $localities AS $locality ) {                     $localities_links .= '
locality_slug . '/">' . $locality->locality_name . '
';                     }                  $items = str_replace('Localities
', 'Localities
'.$localities_links.'

', $items);         }              return $items;     }     add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );      The 'Localities' link ( and all the other links ) was created via Appearance > Menus. This works properly on laptops. But on mobile devices the links do not work. On iOS, the 'Localities' link does not work. On Android, the 'Localities' link shows the subnav, but the subnav links do not work. What is the recommended solution re main nav on mobile? Will I have to use wp_nav_menu to create the whole nav menu via code? And / or a custom walker?


Display all albums in nggallery on a page

I'm using the popular NextGen Gallery / nggallery plugin to handle photo albums and galleries on my site. I can arrange photos into a album and display it using a shortcode no problem, where I'm struggling is that I want to create a master "Photo Galleries" page which will show all of the photo Albums on the site. Any advice / ideas on how to do this? The only vaguely useful suggestion I've found online thus far is to re-arrange the albums so that I have a master albums which has everything else as a sub albums. This feels very suboptimal as each gallery / albums will need to be re-arranged on upload. I found a duplicate of this question elsewhere on the stack network - http://webmasters.stackexchange.com/questions/1858/how-to-show-all-albums-in- wordpress-nextgen-gallery but that one doesn't have an answer and hasn't been migrated to here. Thanks Jona


Quasi-custom API Call Plugin

Basically I am trying to display data from WordPress site #1 on WordPress site #2, and to get around the issue of trying to connect to the database, I thought it might be smarter to make an API-like plugin to return the information. My notion was to build a URL with a parameter which would be used to pull the information I need. Here's all I've got so far...               <?php          if ( isset( $_GET['post_id'] ) ) {              $post_id = $_GET['post_id'];              // use WordPress functionality to retrieve data with $post_id              echo $stuff;          }      Let's say the location of this code is `/wp-content/plugins/custom-api.php`. I want to be able to visit, for example, the URL `/wp-content/plugins/custom- api.php?post_id=420` and have it spit back some information on the page (like post title, thumbnail, whatever). The issue I'm having is that I don't know how to gain access to use the WordPress functions. I know normally with plugins you hook in a function, and then any WP functions you use will work. Here, I'm not trying to hook in; I'm trying to hook out. If I use any WordPress native function, it's not recognized as existing. I'm kind of stumped at the moment. Any suggestions or links to resources I could mull over would be much appreciated.


Plugin not localized properly

I am calling the `load_plugin_textdomain()` function within the `init` action hook the following way :               load_plugin_textdomain( 'my-plugin-domain', false,      dirname( plugin_basename( __FILE__ ) ) . '/i18n' );      I also tried to load it from the `plugins_loaded` action but the result was the same, the plugin doesn't get localized when I set `WPLANG` to `en_US`. I put my `my-plugin-domain-en_US.mo` file into `plugin_base_dir/i18n`. I have no idea why this isn't working. Any suggestion is most welcomed.


Problem with Bootstrap Carousel Integration

HI there i want to show 4 items in one slide of slider it is working but i think i have done lot of hard coding can anyone give me better solution ? here is my code

                     <?php                         $prefix_posts = new WP_Query(                     array(                     'post_type' => 'prefix_portfolio',                          'tax_query' => array(                     array(                     'taxonomy' => 'prefix_portfolio_categories',                     'field'    => 'slug',                     'terms'    => array(                     'Initiatieffase',                 ),                 ),                 ),                 )                 );                      ?>                     <?php if ($prefix_posts->have_posts()): ?>               <?php while ($prefix_posts->have_posts()): ?>               <?php $prefix_posts->the_post(); ?>

                  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?>

                   <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?>

                  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?>

                 <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?>

                     <?php endwhile; ?>               <?php else: ?>
No Posts Found
             <?php endif; ?>            <?php wp_reset_postdata(); ?>


External WordPress API

I'd like to manipulate a WordPress website from another program/website. IS there an API already written that provides access, and authentication, to do this? Ideally, I'll be using a multi-site wordpress instance and I want an outside program to add new sites, send config options to plugins, etc.


How can I remove css from a child theme?

I am using the theme `twentyten` as a parent theme for my child theme. I have other stylesheets I want to use and so I'm trying to figure out how to `wp_deregister_style` for the `style.css` sheet that is printed out in the `head` section of the html. I have checked the global `$wp_styles` variable around the `shutdown` hook and I see the other styles but not `style.css` - how can I get my child theme to stop using it? I realize the theme name and info has to be stored here - I don't want to delete it, I just don't want it to be `enqueued`


How do you add a category to a post in code

We do a lot of post maintenance outside of the WordPress interface and as a result we need ways of categorising posts. Obviously Wordpress has categories (aka taxonomies) on posts and I plan on using them, but haven't found a way that I can do that in code. We also use custom post types extensively so the accepted answer may need to state how to incorporate categories into them.


How can I add a set featured image function to a theme that doesn't already have it built in?

I'm a relative newbie to WP and PHP in general, but now that I'm into it, I've caught the "WP fever" and have ditched asp.net. I finally found a quality theme that I like and I'm considering buying it; I have 4 blogs and counting, but I can't get the basic version of the theme to display the **set featured image** link in my WP admin when creating a post or page. Vanilla install, WP 3.5.1. The support forum isn't that good, and nobody's responded, but I'm quite sure they didn't build this function into their theme. Is it possible to add the **set featured image** function myself, even if I'm not a PHP junkie (yet)? Any guidance in this regard (whether I wanna hear it or not!) would be greatly appreciated!


File upload, uploads only file name

I am working on a simple front end image upload in Wordpress. With this piece of code I can upload to the wordpress media section but I only upload the name and url of the file then, no image. Does anyone know what I need to do to upload the image also? My form:               <form id="dash_action" method="post" enctype="multipart/form-data">             <input type="file" name="file" />              <input name="submit" type="submit" class="button" value="<?php _e( 'Save settings' ); ?>" />          </form><!--End dash_action-->      My PHP form handling:               if( isset( $_POST['submit'] ) ) {              $filename = $_FILES['file']['name'];         $wp_filetype = wp_check_filetype( basename($filename), null );         $wp_upload_dir = wp_upload_dir();         $attachment = array(             'guid' => $wp_upload_dir['subdir'] . '/' . basename( $filename ),              'post_mime_type' => $wp_filetype['type'],             'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),             'post_content' => '',             'post_status' => 'inherit'         );         $attach_id = wp_insert_attachment( $attachment, $filename, 37 );         require_once( ABSPATH . 'wp-admin/includes/image.php' );         $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );         wp_update_attachment_metadata( $attach_id, $attach_data );            }


Is there a seamless solution for submitting plugins to wordpress.org SVN and GitHub?

> **Possible Duplicate:**   >  How-to: push a GitHub repo to the wordpress plugin servers I love WordPress, but I also love GitHub. Would love to know if there is a seamless solution to using both SVN and GitHub for plugin development?


Upgrade to 3.1.1 Fails

When doing an automatic upgrade, I get this: Downloading update from http://wordpress.org/wordpress-3.1.1.zip… Unpacking the update… Could not create directory.: /public_html Installation Failed All my wp files are in /public_html and the directory already exists. The FTP user I am logging in as owns all the Wordpress files, so it cannot be a chmod problem. Is there any reason why this error is occurring?


How to determine if post has widget content?

I've got a registered sidebar called "my-header" that affects the absolute positioning of elements below it in the markup. So I need to execute a query in header.php to determine if the sidebar is present for the current post, and write out a class identifier to my theme's body tag. I'll use this css class to adjust absolute positioning of elements accordingly. Is there a method that can be called, separately from the method that's used to display the sidebar, to determine if the post has widget content for the "my-sidebar" widget? For example, one that just returns true/false? After looking through widgets.php, I tried using is_active_sidebar('my- header') but it returns true for all pages. I need a function that accepts the post as an argument. Otherwise, if none exists, I suppose I'll create my own function.


Add menu page issues (permissions & position)

OK, I have an issue with Sidebar Generator Plugin. This plugin creates subpage called "Sidebars" in WP-Admin. The point is, it is created as a child of "Appearance" page. And I don't want it here, I want "Sidebars" to be a subpage of my own Page named "my-page". I have found this line in the plugin's code:               function admin_menu(){         add_submenu_page('themes.php', 'Sidebars', 'Sidebars', 'manage_options', __FILE__, array('sidebar_generator','admin_page'));     }      And changed 'themes.php' to 'my-page'. Now "Sidebars" is being displayed under My-Page, but when I try to access it it shows: > You do not have sufficient permissions to access this page. Why does it happen and how to fix that? And additional question - the Sidebars subpage displays always at the top of my list of My-Page subpages, how to change that (in fact I want it to be the last subpage of My-Page). Original, full code:               <?php     /*     Plugin Name: Sidebar Generator     Plugin URI: http://www.getson.info     Description: This plugin generates as many sidebars as you need. Then allows you to place them on any page you wish. Version 1.1 now supports themes with multiple sidebars.      Version: 1.1.0     Author: Kyle Getson     Author URI: http://www.kylegetson.com     Copyright (C) 2009 Kyle Robert Getson     */          /*     Copyright (C) 2009 Kyle Robert Getson, kylegetson.com and getson.info          This program is free software; you can redistribute it and/or modify     it under the terms of the GNU General Public License as published by     the Free Software Foundation; either version 3 of the License, or     (at your option) any later version.          This program is distributed in the hope that it will be useful,     but WITHOUT ANY WARRANTY; without even the implied warranty of     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     GNU General Public License for more details.          You should have received a copy of the GNU General Public License     along with this program.  If not, see <http://www.gnu.org/licenses/>.     */          class sidebar_generator {              function sidebar_generator(){             add_action('init',array('sidebar_generator','init'));             add_action('admin_menu',array('sidebar_generator','admin_menu'));             add_action('admin_print_scripts', array('sidebar_generator','admin_print_scripts'));             add_action('wp_ajax_add_sidebar', array('sidebar_generator','add_sidebar') );             add_action('wp_ajax_remove_sidebar', array('sidebar_generator','remove_sidebar') );                  //edit posts/pages             add_action('edit_form_advanced', array('sidebar_generator', 'edit_form'));             add_action('edit_page_form', array('sidebar_generator', 'edit_form'));                  //save posts/pages             add_action('edit_post', array('sidebar_generator', 'save_form'));             add_action('publish_post', array('sidebar_generator', 'save_form'));             add_action('save_post', array('sidebar_generator', 'save_form'));             add_action('edit_page_form', array('sidebar_generator', 'save_form'));              }              function init(){             //go through each sidebar and register it             $sidebars = sidebar_generator::get_sidebars();                       if(is_array($sidebars)){                 foreach($sidebars as $sidebar){                     $sidebar_class = sidebar_generator::name_to_class($sidebar);                     register_sidebar(array(                         'name'=>$sidebar,                         'before_widget' => '
',                         'after_widget' => '
',                         'before_title' => '
',                         'after_title' => '
',                     ));                 }             }         }              function admin_print_scripts(){             wp_print_scripts( array( 'sack' ));             ?>                              <?php         }              function add_sidebar(){             $sidebars = sidebar_generator::get_sidebars();             $name = str_replace(array("\n","\r","\t"),'',$_POST['sidebar_name']);             $id = sidebar_generator::name_to_class($name);             if(isset($sidebars[$id])){                 die("alert('Sidebar already exists, please use a different name.')");             }                  $sidebars[$id] = $name;             sidebar_generator::update_sidebars($sidebars);                  $js = "                 var tbl = document.getElementById('sbg_table');                 var lastRow = tbl.rows.length;                 // if there's no header row in the table, then iteration = lastRow + 1                 var iteration = lastRow;                 var row = tbl.insertRow(lastRow);                      // left cell                 var cellLeft = row.insertCell(0);                 var textNode = document.createTextNode('$name');                 cellLeft.appendChild(textNode);                      //middle cell                 var cellLeft = row.insertCell(1);                 var textNode = document.createTextNode('$id');                 cellLeft.appendChild(textNode);                      //var cellLeft = row.insertCell(2);                 //var textNode = document.createTextNode('[Remove]');                 //cellLeft.appendChild(textNode)                      var cellLeft = row.insertCell(2);                 removeLink = document.createElement('a');                 linkText = document.createTextNode('remove');                 removeLink.setAttribute('onclick', 'remove_sidebar_link(\'$name\')');                 removeLink.setAttribute('href', 'javacript:void(0)');                      removeLink.appendChild(linkText);                 cellLeft.appendChild(removeLink);                       ";                       die( "$js");         }              function remove_sidebar(){             $sidebars = sidebar_generator::get_sidebars();             $name = str_replace(array("\n","\r","\t"),'',$_POST['sidebar_name']);             $id = sidebar_generator::name_to_class($name);             if(!isset($sidebars[$id])){                 die("alert('Sidebar does not exist.')");             }             $row_number = $_POST['row_number'];             unset($sidebars[$id]);             sidebar_generator::update_sidebars($sidebars);             $js = "                 var tbl = document.getElementById('sbg_table');                 tbl.deleteRow($row_number)                  ";             die($js);         }              function admin_menu(){             add_submenu_page('themes.php', 'Sidebars', 'Sidebars', 'manage_options', __FILE__, array('sidebar_generator','admin_page'));         }              function admin_page(){             ?>

Sidebar Generator

                     The sidebar name is for your use only. It will not be visible to any of your visitors.                      A CSS class is assigned to each of your sidebar, use this styling to customize the sidebars.

                     + Add Sidebar

                         Name	                         CSS class	                         Remove
                     <?php                     $sidebars = sidebar_generator::get_sidebars();                     //$sidebars = array('bob','john','mike','asdf');                     if(is_array($sidebars) && !empty($sidebars)){                         $cnt=0;                         foreach($sidebars as $sidebar){                             $alt = ($cnt%2 == 0 ? 'alternate' : '');                     ?>                     <tr class="<?php echo $alt?>">                         <?php echo $sidebar; ?>	                         <?php echo sidebar_generator::name_to_class($sidebar); ?>	                         <a href="javascript:void(0);" onclick="return remove_sidebar_link('<?php echo $sidebar; ?>',<?php echo $cnt+1; ?>);" title="Remove this sidebar">remove
                     <?php                             $cnt++;                         }                     }else{                         ?>
                             No Sidebars defined
                         <?php                     }                     ?>

Donate

                         Support the further development of this plugin.
                     <form action="https://www.paypal.com/cgi-bin/webscr" method="post">                     <input type="hidden" name="cmd" value="_s-xclick">                     <input type="hidden" name="hosted_button_id" value="9271055">                     <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">                                          </form>

             <?php         }              /**          * for saving the pages/post         */         function save_form($post_id){             $is_saving = $_POST['sbg_edit'];             if(!empty($is_saving)){                 delete_post_meta($post_id, 'sbg_selected_sidebar');                 delete_post_meta($post_id, 'sbg_selected_sidebar_replacement');                 add_post_meta($post_id, 'sbg_selected_sidebar', $_POST['sidebar_generator']);                 add_post_meta($post_id, 'sbg_selected_sidebar_replacement', $_POST['sidebar_generator_replacement']);             }                }              function edit_form(){             global $post;             $post_id = $post;             if (is_object($post_id)) {                 $post_id = $post_id->ID;             }             $selected_sidebar = get_post_meta($post_id, 'sbg_selected_sidebar', true);             if(!is_array($selected_sidebar)){                 $tmp = $selected_sidebar;                  $selected_sidebar = array();                  $selected_sidebar[0] = $tmp;             }             $selected_sidebar_replacement = get_post_meta($post_id, 'sbg_selected_sidebar_replacement', true);             if(!is_array($selected_sidebar_replacement)){                 $tmp = $selected_sidebar_replacement;                  $selected_sidebar_replacement = array();                  $selected_sidebar_replacement[0] = $tmp;             }             ?>

Sidebars

                         <input name="sbg_edit" type="hidden" value="sbg_edit" />
                             Select the sidebar you wish to display on this page, and which sidebar it will replace. (leave unselected to use the default sidebar everywhere)

                         <?php                          global $wp_registered_sidebars;                         //var_dump($wp_registered_sidebars);                                     for($i=0;$i<5;$i++){ ?>
Replace                                  <select name="sidebar_generator[<?=$i?>]">                                     <option value="0"<?php if($selected_sidebar[$i] == ''){ echo " selected";} ?>>WP Default Sidebar</option>                                 <?php                                 $sidebars = $wp_registered_sidebars;// sidebar_generator::get_sidebars();                                 if(is_array($sidebars) && !empty($sidebars)){                                     foreach($sidebars as $sidebar){                                         if($selected_sidebar[$i] == $sidebar['name']){                                             echo "<option value='{$sidebar['name']}' selected>{$sidebar['name']}</option>\n";                                         }else{                                             echo "<option value='{$sidebar['name']}'>{$sidebar['name']}</option>\n";                                         }                                     }                                 }                                 ?>                                 </select>                                  with                                   <select name="sidebar_generator_replacement[<?=$i?>]">                                     <option value="0"<?php if($selected_sidebar_replacement[$i] == ''){ echo " selected";} ?>>None</option>                                 <?php                                      $sidebar_replacements = $wp_registered_sidebars;//sidebar_generator::get_sidebars();                                 if(is_array($sidebar_replacements) && !empty($sidebar_replacements)){                                     foreach($sidebar_replacements as $sidebar){                                         if($selected_sidebar_replacement[$i] == $sidebar['name']){                                             echo "<option value='{$sidebar['name']}' selected>{$sidebar['name']}</option>\n";                                         }else{                                             echo "<option value='{$sidebar['name']}'>{$sidebar['name']}</option>\n";                                         }                                     }                                 }                                 ?>                                 </select>
                             <?php } ?>

                  <?php         }              /**          * called by the action get_sidebar. this is what places this into the theme         */         function get_sidebar($name="0"){             if(!is_singular()){                 if($name != "0"){                     dynamic_sidebar($name);                 }else{                     dynamic_sidebar();                 }                 return;//dont do anything             }             global $wp_query;             $post = $wp_query->get_queried_object();             $selected_sidebar = get_post_meta($post->ID, 'sbg_selected_sidebar', true);             $selected_sidebar_replacement = get_post_meta($post->ID, 'sbg_selected_sidebar_replacement', true);             $did_sidebar = false;             //this page uses a generated sidebar             if($selected_sidebar != '' && $selected_sidebar != "0"){                 echo "\n\n\n";                 if(is_array($selected_sidebar) && !empty($selected_sidebar)){                     for($i=0;$i<sizeof($selected_sidebar);$i++){                                                  if($name == "0" && $selected_sidebar[$i] == "0" &&  $selected_sidebar_replacement[$i] == "0"){                             //echo "\n\n";                             dynamic_sidebar();//default behavior                             $did_sidebar = true;                             break;                         }elseif($name == "0" && $selected_sidebar[$i] == "0"){                             //we are replacing the default sidebar with something                             //echo "\n\n";                             dynamic_sidebar($selected_sidebar_replacement[$i]);//default behavior                             $did_sidebar = true;                             break;                         }elseif($selected_sidebar[$i] == $name){                             //we are replacing this $name                             //echo "\n\n";                             $did_sidebar = true;                             dynamic_sidebar($selected_sidebar_replacement[$i]);//default behavior                             break;                         }                         //echo "\n";                     }                 }                 if($did_sidebar == true){                     echo "\n\n\n";                     return;                 }                 //go through without finding any replacements, lets just send them what they asked for                 if($name != "0"){                     dynamic_sidebar($name);                 }else{                     dynamic_sidebar();                 }                 echo "\n\n\n";                 return;                      }else{                 if($name != "0"){                     dynamic_sidebar($name);                 }else{                     dynamic_sidebar();                 }             }         }              /**          * replaces array of sidebar names         */         function update_sidebars($sidebar_array){             $sidebars = update_option('sbg_sidebars',$sidebar_array);         }                 /**          * gets the generated sidebars         */         function get_sidebars(){             $sidebars = get_option('sbg_sidebars');             return $sidebars;         }         function name_to_class($name){             $class = str_replace(array(' ',',','.','"',"'",'/',"\\",'+','=',')','(','*','&','^','%','$','#','@','!','~','`','<','>','?','[',']','{','}','|',':',),'',$name);             return $class;         }          }     $sbg = new sidebar_generator;          function generated_dynamic_sidebar($name='0'){         sidebar_generator::get_sidebar($name);           return true;     }     ?>


Why are some of my thumbnails not being generated?

I am currently developing my new theme over at testing.detailsofmylife.net and I am using a WooThemes template as my basic design. I want to try and include their WooTabs widget as graphically I think it is quite appealing for displaying post data to visitors. I know a lot of you aren't fond of TimThumb but it is the script that the theme uses to generate thumbnails so I need to try and get it working so the layout can finally work perfectly. As you can see from the widget on my site, two of the thumbnails have not been generated by the TimThumb function, but I cannot fully understand why. For example, a working thumbnail url looks like this in the widget:               http://testing.detailsofmylife.net/wp-content/themes/headlines/thumb.php?src=http://testing.detailsofmylife.net/wp-content/uploads/2010/09/Claire-Maguire-Aint-Nobody-Breakage-Remix.jpg&w=50&h=50&zc=1&q=90      but a broken thumbnail url looks like this:               http://testing.detailsofmylife.net/wp-content/themes/headlines/thumb.php?src=http://media.detailsofmylife.net/uploads/2010/04/flux+pavilion.jpg&w=50&h=50&zc=1&q=90      The problem occurs I think due to the location of the media, but I have added both domains to the list of external domains that are allowed to work with the script. And if you check the image urls by themselves (working v.s. not working) then you can see that they are both working correctly by themselves. Surely then they should both operate within the script? Any help would be much appreciated as it is driving me slightly mental. A copy of my code for TimThumb is available at the end of the post. If you need any other data/information let me know :) Thanks!               <?php     /**      * TimThumb script created by Ben Gillbanks, originally created by Tim McDaniels and Darren Hoyt      * http://code.google.com/p/timthumb/      *       * GNU General Public License, version 2      * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html      *      * Examples and documentation available on the project homepage      * http://www.binarymoon.co.uk/projects/timthumb/      */          define ('CACHE_SIZE', 1000);                // number of files to store before clearing cache     define ('CACHE_CLEAR', 20);                 // maximum number of files to delete on each cache clear     define ('CACHE_USE', TRUE);                 // use the cache files? (mostly for testing)     define ('CACHE_MAX_AGE', 864000);           // time to cache in the browser     define ('VERSION', '1.26');                 // version number (to force a cache refresh)     define ('DIRECTORY_CACHE', './cache');      // cache directory     define ('MAX_WIDTH', 1500);                 // maximum image width     define ('MAX_HEIGHT', 1500);                // maximum image height     define ('ALLOW_EXTERNAL', FALSE);           // allow external website (override security precaution - not advised!)     define ('MEMORY_LIMIT', '30M');             // set PHP memory limit     define ('MAX_FILE_SIZE', 1500000);          // file size limit to prevent possible DOS attacks (roughly 1.5 megabytes)     define ('CURL_TIMEOUT', 10);                // timeout duration. Tweak as you require (lower = better)          // external domains that are allowed to be displayed on your website     $allowedSites = array (         'photobucket.com',         'detailsofmylife.net',         'testing.detailsofmylife.net',         'detailsofmylife.net',         'img.youtube.com',         'media.detailsofmylife.net',     );          // STOP MODIFYING HERE!     // --------------------          // sort out image source     $src = get_request ('src', '');     if ($src == '' || strlen ($src) <= 3) {         display_error ('no image specified');     }          // clean params before use     $src = clean_source ($src);          // get mime type of src     $mime_type = mime_type ($src);          // used for external websites only     $external_data_string = '';          // generic file handle for reading and writing to files     $fh = '';          // check to see if this image is in the cache already     // if already cached then display the image and die     check_cache ($mime_type);          // cache doesn't exist and then process everything     // check to see if GD function exist     if (!function_exists ('imagecreatetruecolor')) {         display_error ('GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library');     }          if (function_exists ('imagefilter') && defined ('IMG_FILTER_NEGATE')) {         $imageFilters = array (             1 => array (IMG_FILTER_NEGATE, 0),             2 => array (IMG_FILTER_GRAYSCALE, 0),             3 => array (IMG_FILTER_BRIGHTNESS, 1),             4 => array (IMG_FILTER_CONTRAST, 1),             5 => array (IMG_FILTER_COLORIZE, 4),             6 => array (IMG_FILTER_EDGEDETECT, 0),             7 => array (IMG_FILTER_EMBOSS, 0),             8 => array (IMG_FILTER_GAUSSIAN_BLUR, 0),             9 => array (IMG_FILTER_SELECTIVE_BLUR, 0),             10 => array (IMG_FILTER_MEAN_REMOVAL, 0),             11 => array (IMG_FILTER_SMOOTH, 0),         );     }          // get standard input properties     $new_width =  (int) abs (get_request ('w', 0));     $new_height = (int) abs (get_request ('h', 0));     $zoom_crop = (int) get_request ('zc', 0);     $quality = (int) abs (get_request ('q', 75));     $align = get_request ('a', 'c');     $filters = get_request ('f', '');     $sharpen = (bool) get_request ('s', 0);          // set default width and height if neither are set already     if ($new_width == 0 && $new_height == 0) {         $new_width = 100;         $new_height = 100;     }          // ensure size limits can not be abused     $new_width = min ($new_width, MAX_WIDTH);     $new_height = min ($new_height, MAX_HEIGHT);          // set memory limit to be able to have enough space to resize larger images     ini_set ('memory_limit', MEMORY_LIMIT);          if (file_exists ($src)) {              // open the existing image         $image = open_image ($mime_type, $src);         if ($image === false) {             display_error ('Unable to open image : ' . $src);         }              // Get original width and height         $width = imagesx ($image);         $height = imagesy ($image);         $origin_x = 0;         $origin_y = 0;              // generate new w/h if not provided         if ($new_width && !$new_height) {             $new_height = floor ($height * ($new_width / $width));         } else if ($new_height && !$new_width) {             $new_width = floor ($width * ($new_height / $height));         }              // scale down and add borders         if ($zoom_crop == 3) {                  $final_height = $height * ($new_width / $width);                  if ($final_height > $new_height) {                 $new_width = $width * ($new_height / $height);             } else {                 $new_height = $final_height;             }              }              // create a new true color image         $canvas = imagecreatetruecolor ($new_width, $new_height);         imagealphablending ($canvas, false);              // Create a new transparent color for image         $color = imagecolorallocatealpha ($canvas, 0, 0, 0, 127);              // Completely fill the background of the new image with allocated color.         imagefill ($canvas, 0, 0, $color);              // scale down and add borders         if ($zoom_crop == 2) {                  $final_height = $height * ($new_width / $width);                  if ($final_height > $new_height) {                      $origin_x = $new_width / 2;                 $new_width = $width * ($new_height / $height);                 $origin_x = round ($origin_x - ($new_width / 2));                  } else {                      $origin_y = $new_height / 2;                 $new_height = $final_height;                 $origin_y = round ($origin_y - ($new_height / 2));                  }              }              // Restore transparency blending         imagesavealpha ($canvas, true);              if ($zoom_crop > 0) {                  $src_x = $src_y = 0;             $src_w = $width;             $src_h = $height;                  $cmp_x = $width / $new_width;             $cmp_y = $height / $new_height;                  // calculate x or y coordinate and width or height of source             if ($cmp_x > $cmp_y) {                      $src_w = round ($width / $cmp_x * $cmp_y);                 $src_x = round (($width - ($width / $cmp_x * $cmp_y)) / 2);                  } else if ($cmp_y > $cmp_x) {                      $src_h = round ($height / $cmp_y * $cmp_x);                 $src_y = round (($height - ($height / $cmp_y * $cmp_x)) / 2);                  }                  // positional cropping!             switch ($align) {                 case 't':                 case 'tl':                 case 'lt':                 case 'tr':                 case 'rt':                     $src_y = 0;                     break;                      case 'b':                 case 'bl':                 case 'lb':                 case 'br':                 case 'rb':                     $src_y = $height - $src_h;                     break;                      case 'l':                 case 'tl':                 case 'lt':                 case 'bl':                 case 'lb':                     $src_x = 0;                     break;                      case 'r':                 case 'tr':                 case 'rt':                 case 'br':                 case 'rb':                     $src_x = $width - $new_width;                     $src_x = $width - $src_w;                     break;                      default:                     break;             }                  imagecopyresampled ($canvas, $image, $origin_x, $origin_y, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h);              } else {                  // copy and resize part of an image with resampling             imagecopyresampled ($canvas, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);              }              if ($filters != '' && function_exists ('imagefilter') && defined ('IMG_FILTER_NEGATE')) {             // apply filters to image             $filterList = explode ('|', $filters);             foreach ($filterList as $fl) {                      $filterSettings = explode (',', $fl);                 if (isset ($imageFilters[$filterSettings[0]])) {                          for ($i = 0; $i < 4; $i ++) {                         if (!isset ($filterSettings[$i])) {                             $filterSettings[$i] = null;                         } else {                             $filterSettings[$i] = (int) $filterSettings[$i];                         }                     }                          switch ($imageFilters[$filterSettings[0]][1]) {                              case 1:                                  imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1]);                             break;                              case 2:                                  imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2]);                             break;                              case 3:                                  imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2], $filterSettings[3]);                             break;                              case 4:                                  imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2], $filterSettings[3], $filterSettings[4]);                             break;                              default:                                  imagefilter ($canvas, $imageFilters[$filterSettings[0]][0]);                             break;                          }                 }             }         }              // sharpen image         if ($sharpen && function_exists ('imageconvolution')) {                  $sharpenMatrix = array (                 array (-1,-1,-1),                 array (-1,16,-1),                 array (-1,-1,-1),             );                  $divisor = 8;             $offset = 0;                  imageconvolution ($canvas, $sharpenMatrix, $divisor, $offset);              }              // output image to browser based on mime type         show_image ($mime_type, $canvas);              // remove image from memory         imagedestroy ($canvas);              // if not in cache then clear some space and generate a new file         clean_cache ();              die ();          } else {              if (strlen ($src)) {             display_error ('image ' . $src . ' not found');         } else {             display_error ('no source specified');         }          }               /**      *      * @global <type> $quality      * @param <type> $mime_type      * @param <type> $image_resized       */     function show_image ($mime_type, $image_resized) {              global $quality;              $cache_file = get_cache_file ($mime_type);              if (strpos ($mime_type, 'jpeg') > 1) {             imagejpeg ($image_resized, $cache_file, $quality);         } else {             imagepng ($image_resized, $cache_file, floor ($quality * 0.09));         }              show_cache_file ($mime_type);          }               /**      *      * @param <type> $property      * @param <type> $default      * @return <type>       */     function get_request ($property, $default = 0) {              if (isset ($_GET[$property])) {             return $_GET[$property];         } else {             return $default;         }          }               /**      *      * @param <type> $mime_type      * @param <type> $src      * @return <type>      */     function open_image ($mime_type, $src) {              if (strpos ($mime_type, 'jpeg') !== false) {             $image = imagecreatefromjpeg ($src);         } elseif (strpos ($mime_type, 'png') !== false) {             $image = imagecreatefrompng ($src);         } elseif (strpos ($mime_type, 'gif') !== false) {             $image = imagecreatefromgif ($src);         }              return $image;          }          /**      * clean out old files from the cache      * you can change the number of files to store and to delete per loop in the defines at the top of the code      *      * @return <type>      */     function clean_cache () {              // add an escape         // Reduces the amount of cache clearing to save some processor speed         if (rand (1, 50) > 10) {             return true;         }              flush ();              $files = glob (DIRECTORY_CACHE . '/*', GLOB_BRACE);              if (count ($files) > CACHE_SIZE) {                  $yesterday = time () - (24 * 60 * 60);                  usort ($files, 'filemtime_compare');             $i = 0;                  foreach ($files as $file) {                      $i ++;                      if ($i >= CACHE_CLEAR) {                     return;                 }                      if (@filemtime ($file) > $yesterday) {                     return;                 }                      if (file_exists ($file)) {                     unlink ($file);                 }                  }              }          }               /**      * compare the file time of two files      *      * @param <type> $a      * @param <type> $b      * @return <type>      */     function filemtime_compare ($a, $b) {              $break = explode ('/', $_SERVER['SCRIPT_FILENAME']);         $filename = $break[count ($break) - 1];         $filepath = str_replace ($filename, '', $_SERVER['SCRIPT_FILENAME']);              $file_a = realpath ($filepath . $a);         $file_b = realpath ($filepath . $b);              return filemtime ($file_a) - filemtime ($file_b);          }               /**      * determine the file mime type      *      * @param <type> $file      * @return <type>      */     function mime_type ($file) {              $file_infos = getimagesize ($file);         $mime_type = $file_infos['mime'];              // no mime type         if (empty ($mime_type)) {             display_error ('no mime type specified');         }              // use mime_type to determine mime type         if (!preg_match ("/jpg|jpeg|gif|png/i", $mime_type)) {             display_error ('Invalid src mime type: ' . $mime_type);         }              return strtolower ($mime_type);          }               /**      *      * @param <type> $mime_type      */     function check_cache ($mime_type) {              if (CACHE_USE) {                  if (!show_cache_file ($mime_type)) {                 // make sure cache dir exists                 if (!file_exists (DIRECTORY_CACHE)) {                     // give 777 permissions so that developer can overwrite                     // files created by web server user                     mkdir (DIRECTORY_CACHE);                     chmod (DIRECTORY_CACHE, 0777);                 }             }              }          }               /**      *      * @param <type> $mime_type      * @return <type>       */     function show_cache_file ($mime_type) {              // use browser cache if available to speed up page load         if (isset ($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {             if (strtotime ($_SERVER['HTTP_IF_MODIFIED_SINCE']) < strtotime('now')) {                 header ('HTTP/1.1 304 Not Modified');                 die ();             }         }              $cache_file = get_cache_file ($mime_type);              if (file_exists ($cache_file)) {                  // change the modified headers             $gmdate_expires = gmdate ('D, d M Y H:i:s', strtotime ('now +10 days')) . ' GMT';             $gmdate_modified = gmdate ('D, d M Y H:i:s') . ' GMT';                  // send content headers then display image             header ('Content-Type: ' . $mime_type);             header ('Accept-Ranges: bytes');             header ('Last-Modified: ' . $gmdate_modified);             header ('Content-Length: ' . filesize ($cache_file));             header ('Cache-Control: max-age=' . CACHE_MAX_AGE . ', must-revalidate');             header ('Expires: ' . $gmdate_expires);                  if (!@readfile ($cache_file)) {                 $content = file_get_contents ($cache_file);                 if ($content != FALSE) {                     echo $content;                 } else {                     display_error ('cache file could not be loaded');                 }             }                  die ();              }              return FALSE;          }               /**      *      * @staticvar string $cache_file      * @param <type> $mime_type      * @return string      */     function get_cache_file ($mime_type) {              static $cache_file;         global $src;              $file_type = '.png';              if (strpos ($mime_type, 'jpeg') > 1) {             $file_type = '.jpg';         }              if (!$cache_file) {             // filemtime is used to make sure updated files get recached             $cache_file = DIRECTORY_CACHE . '/' . md5 ($_SERVER ['QUERY_STRING'] . VERSION . filemtime ($src)) . $file_type;         }              return $cache_file;          }               /**      *      * @param <type> $url      * @return <type>       */     function validate_url ($url) {         $pattern = "/\b(?:(?:https?):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i";         return preg_match ($pattern, $url);     }               /**      *      * @global array $allowedSites      * @param string $src      * @return string      */     function check_external ($src) {              global $allowedSites;              // work out file details         $fileDetails = pathinfo ($src);         $filename = 'external_' . md5 ($src);         $local_filepath = DIRECTORY_CACHE . '/' . $filename . '.' . strtolower ($fileDetails['extension']);              // only do this stuff the file doesn't already exist         if (!file_exists ($local_filepath)) {                  if (strpos (strtolower ($src), 'http://') !== false || strpos (strtolower ($src), 'https://') !== false) {                      if (!validate_url ($src)) {                     display_error ('invalid url');                 }                      $url_info = parse_url ($src);                      // convert youtube video urls                 // need to tidy up the code                      if ($url_info['host'] == 'www.youtube.com' || $url_info['host'] == 'youtube.com') {                     parse_str ($url_info['query']);                          if (isset ($v)) {                         $src = 'http://img.youtube.com/vi/' . $v . '/0.jpg';                         $url_info['host'] = 'img.youtube.com';                     }                 }                      // check allowed sites (if required)                 if (ALLOW_EXTERNAL) {                          $isAllowedSite = true;                      } else {                          $isAllowedSite = false;                     foreach ($allowedSites as $site) {                         if (strpos (strtolower ($url_info['host']), $site) !== false) {                             $isAllowedSite = true;                         }                     }                      }                      // if allowed                 if ($isAllowedSite) {                          if (function_exists ('curl_init')) {                              global $fh;                              $fh = fopen ($local_filepath, 'w');                         $ch = curl_init ($src);                              curl_setopt ($ch, CURLOPT_TIMEOUT, CURL_TIMEOUT);                         curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');                         curl_setopt ($ch, CURLOPT_URL, $src);                         curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);                         curl_setopt ($ch, CURLOPT_HEADER, 0);                         curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);                         curl_setopt ($ch, CURLOPT_FILE, $fh);                         curl_setopt ($ch, CURLOPT_WRITEFUNCTION, 'curl_write');                              // error so die                         if (curl_exec ($ch) === FALSE) {                             unlink ($local_filepath);                             touch ($local_filepath);                             display_error ('error reading file ' . $src . ' from remote host: ' . curl_error ($ch));                         }                              curl_close ($ch);                         fclose ($fh);                          } else {                              if (!$img = file_get_contents ($src)) {                             display_error ('remote file for ' . $src . ' can not be accessed. It is likely that the file permissions are restricted');                         }                              if (file_put_contents ($local_filepath, $img) == FALSE) {                             display_error ('error writing temporary file');                         }                          }                          if (!file_exists ($local_filepath)) {                         display_error ('local file for ' . $src . ' can not be created');                     }                          $src = $local_filepath;                      } else {                          display_error ('remote host "' . $url_info['host'] . '" not allowed');                      }                  }              } else {                  $src = $local_filepath;              }              return $src;          }               /**      * callback for curl command to receive external images      * limit the amount of data downloaded from external servers      *       * @global <type> $data_string      * @param <type> $handle      * @param <type> $data      * @return <type>      */     function curl_write ($handle, $data) {              global $external_data_string, $fh;              fwrite ($fh, $data);         $external_data_string .= $data;              if (strlen ($external_data_string) > MAX_FILE_SIZE) {             return 0;         } else {             return strlen ($data);         }          }               /**      * tidy up the image source url      *      * @param <type> $src      * @return string      */     function clean_source ($src) {              $host = str_replace ('www.', '', $_SERVER['HTTP_HOST']);         $regex = "/^(http(s|):\/\/)(www\.|)" . $host . "\//i";              $src = preg_replace ($regex, '', $src);         $src = strip_tags ($src);         $src = check_external ($src);              // remove slash from start of string         if (strpos ($src, '/') === 0) {             $src = substr ($src, -(strlen ($src) - 1));         }              // don't allow users the ability to use '../'         // in order to gain access to files below document root         $src = preg_replace ("/\.\.+\//", "", $src);              // get path to image on file system         $src = get_document_root ($src) . '/' . $src;              if (!is_file ($src)) {             display_error ('source is not a valid file');         }              if (filesize ($src) > MAX_FILE_SIZE) {             display_error ('source file is too big (filesize > MAX_FILE_SIZE)');         }              if (filesize ($src) <= 0) {             display_error ('source file <= 0 bytes. Possible external file download error (file is too large)');         }              return realpath ($src);          }               /**      *      * @param <type> $src      * @return string      */     function get_document_root ($src) {              // check for unix servers         if (file_exists ($_SERVER['DOCUMENT_ROOT'] . '/' . $src)) {             return $_SERVER['DOCUMENT_ROOT'];         }              // check from script filename (to get all directories to timthumb location)         $parts = array_diff (explode ('/', $_SERVER['SCRIPT_FILENAME']), explode ('/', $_SERVER['DOCUMENT_ROOT']));              $path = $_SERVER['DOCUMENT_ROOT'];              foreach ($parts as $part) {             $path .= '/' . $part;             if (file_exists ($path . '/' . $src)) {                 return $path;             }         }              // special check for microsoft servers         if (!isset ($_SERVER['DOCUMENT_ROOT'])) {             $path = str_replace ("/", "\\", $_SERVER['ORIG_PATH_INFO']);             $path = str_replace ($path, '', $_SERVER['SCRIPT_FILENAME']);                  if (file_exists ($path . '/' . $src)) {                 return $path;             }         }              display_error ('file not found');          }               /**      * generic error message      *      * @param <type> $errorString      */     function display_error ($errorString = '') {              header ('HTTP/1.1 400 Bad Request');         echo '<pre>' . htmlentities ($errorString);         echo '<br />Query String : ' . htmlentities ($_SERVER['QUERY_STRING']);         echo '<br />TimThumb version : ' . VERSION . '</pre>';         die ();          }


All post ids are the same after this query but rewind_posts() does not seem to work here?

I'm executing a query inside of header.php which is apparently resetting the $post object so that all pages are getting the $post->ID of the last element in this loop.               $mypostsheader = get_posts(array('cat' => "$cat,-$catHidden",'numberposts' => $cb2_current_count));     $current_page = get_post( $current_page );?>

<?php foreach($mypostsheader as $idx=>$post){             if ( $post->ID == $current_page->ID )//do something; }      I've tried adding a rewind_posts() at the end of this function and also at the end of header.php but my echo $post->ID inside of page.php still returns the id of the last element in the query. Any ideas?


Super administrator db name

As I cant test this(cant find any docs and dont have an multisite setup) I need to know the db name of the Super Administrator. So how is this role stored inside the wp db? It's probably something like 'super_administrator'...?


Showing User's Post Counts by Custom Post Type in the Admin's User List?

I'm trying to figure out how to hook into the `/wp-admin/users.php` manage page to create custom columns for showing the number of posts users have for the custom post types on **WPHonors.com**. I created a trac ticket for this but @nacin explained why it's a job more for a plugin to do instead. I have been unable to find a way to manipulate the output of the users table, so I can add custom columns for CPTs post counts for each user. And that may have something to do with the question @nacin asked, what would the post count numbers link to. For the current 'post' post count a user has, it links to the post manage page, showing all posts for that user (`/wp- admin/edit.php?author=%author_id%`). If I were to link it somewhere, it would be to:               /wp-admin/edit.php?post_type=%post_type%&author=%author_id%      If that were even somehow possible, I guess. But I don't even necessarily need to link it to anywhere. I mostly want to just show CPT post counts for each person, having `600` users and a combined total of `300+` posts across `4` custom post types. Admins are only one who can submit `'post'` posts, so that column in the user's page is useless.


User-based media gallery

I'm building a site that uses both WordPress and BuddyPress and I'm looking to build a custom section whereby the user can upload work and people can comment/rate it. I've browsed around at various different options but it would seem using a custom post type like and then allowing members to submit content would be the best option. Is their a better way to do this? Or do you think post types are the best option. To get an idea of the kind of functionality it will require: http://dribbble.com/ The idea will be to have images as URLs like domain.com/designs/my-awesome- work-2201/ And when viewing member profiles you will be able to view their latest work etc, so they need to be linked up with a user and not just floating randomly in the database. Not sure how easy this will be to do with normal users who are not authors/editors. Thoughts? Thanks


Taxonomy count per Post type

Below is the code i use to output the post tag (taxonomy) count/number. I want to be able to split the count based on post type that the taxonomy features in (rather than the total number). So i have the default "post" Post type, aswell as "blogs", & "pics". I want the taxonomy count to display something like: x posts | x blogs | x Pics                           <?php                 $tags = get_tags( array('name__like' => "a", 'order' => 'ASC') );                 foreach ( (array) $tags as $tag ) { ?>
                                                     <a href="<?php echo get_tag_link( $tag->term_id ) ?>">                                       <?php echo $tag->name ?>                             <?php echo $tag->count ?>
                 <?php } ?>


How to make sexy bookmarks plugin work in WPMU

We have Wordpress 3.0 working as multi site, and we want all the blogs in the system to have the plugin "sexy bookmarks". But it seems to be working only in the main blog.   Does anyone know how to make it work in all blogs (what code to add to make it work that way)? Or is there a plugin like sexy bookmarks that adds social network icons to each post that works in a multi site version of Wordpress 3.0?


Get urls of images in a gallery?

I need to retrieve the URLs for the images inside a gallery, what's the appropriate SQL query for this, based on the post ID? I currently have something like the following which I found on via google, but I don't know how to access the global WP variable from outside Wordpress - what do I need to do?               function getGallery($id)     {      global $wpdb;           //SQL query to retrieve all attachment of mime type image/jpeg from the given post      $querystr = "          SELECT ID, post_name, guid, meta_value          FROM $wpdb->posts wposts          INNER JOIN $wpdb->postmeta meta ON meta.post_id = wposts.ID AND meta.meta_key = '_wp_attachment_metadata'          WHERE wposts.post_type = 'attachment'          AND wposts.post_parent = '".$id."'          AND wposts.post_mime_type = 'image/jpeg'       ";           //get result set from the query      $pictures = $wpdb->get_results($querystr, ARRAY_A);           //return resultset      return $pictures;     }


Problem duplicated shortlinks bitly

I've this plugin to create shortlink using the bitly API, but there's a problem!               function yoast_bitly_shortlink($url, $id, $context, $allow_slugs) {         if ( ( is_singular() && !is_preview() ) || $context == 'post' ) {             $short = get_post_meta($id, '_yoast_bitlylink', true);             if ( !$short || $short == '' ) {                 if ( !defined('BITLY_USERNAME') || !defined('BITLY_APIKEY') ) {                     $short = 'http://yoast.com/wordpress/bitly-shortlinks/configure-bitly/';                 } else {                     $url = get_permalink( $id );                     $req = 'http://api.bit.ly/v3/shorten?format=txt&longUrl='.$url.'&login='.BITLY_USERNAME.'&apiKey='.BITLY_APIKEY;                     if ( defined('BITLY_JMP') && BITLY_JMP )                         $req .= '&domain=j.mp';                     $resp = wp_remote_get( $req );                     if ( !is_wp_error( $resp ) && is_array( $resp['response'] ) && 200 == $resp['response']['code'] ) {                         $short = trim( $resp['body'] );                         update_post_meta( $id, '_yoast_bitlylink', $short);                     }                 }             }             return $short;         }         return false;     }     add_filter( 'pre_get_shortlink', 'yoast_bitly_shortlink', 99, 4 );          function yoast_bitly_admin_bar_menu() {         global $wp_admin_bar, $post;              if ( !isset($post->ID) )             return;              $short = wp_get_shortlink( $post->ID, 'query' );              if ( is_singular() && !is_preview() ) {             if ( $short != 'http://yoast.com/wordpress/bitly-shortlinks/configure-bitly/' )                 $shortstats = $short.'+';                  // Remove the old shortlink menu, because it has some weird JS issues with admin bar when giving it submenu's.             $wp_admin_bar->remove_menu('get-shortlink');             $wp_admin_bar->add_menu( array( 'id' => 'shortlink', 'title' => __( 'Bit.ly' ), 'href' => 'javascript:prompt('Short Link:', ''.$short.''); return false;' ) );             $wp_admin_bar->add_menu( array( 'parent' => 'shortlink', 'id' => 'yoast_bitly-link', 'title' => __( 'Bit.ly Link' ), 'href' => 'javascript:prompt('Short Link:', ''.$short.''); return false;' ) );             $wp_admin_bar->add_menu( array( 'parent' => 'shortlink', 'id' => 'yoast_bitly-twitterlink', 'title' => __( 'Share on Twitter' ), 'href' => 'http://twitter.com/?status='.str_replace('+','%20', urlencode( $post->post_title.' - '.$short) ) ) );             $wp_admin_bar->add_menu( array( 'parent' => 'shortlink', 'id' => 'yoast_bitly-stats', 'title' => __( 'Bit.ly Stats' ), 'href' => $shortstats, 'meta' => array('target' => '_blank') ) );         }     }     add_action( 'admin_bar_menu', 'yoast_bitly_admin_bar_menu', 95 );      It creates 2 bitly links of every post one is the `/?p=12345` and the other is `/post-name` I Schedule all my posts, so, I've noticed that `?p=12345` is created on auto saves, previews and when Scheduled and the `/post-name` is created once the post is published... And unfortunately `?p=12345` is set as default short url; `?p=12345` = `bit.ly/sdfssdfd` and the other one is ignored.. What should I do to force it to create only 1 link of `/post-name` and set it as default instead of the other one?! I've tried this:               $mypost = get_page( $id );       if ( !in_array($mypost->post_status, array('future', 'publish')) ) {         return "Post must be published to get a shortlink";       }      but as it's noted in return, post must be published to get a shortlink (it creates 1 link but the `/?p=12345` in bitly website but it's not visible back on wordpress)... I guess I need, instead of published, the url to be created once Scheduled.. so I've tried to change               $mypost = get_page( $id );       if ( !in_array($mypost->post_status, array('schedule', 'future')) ) {         return "Post must be published to get a shortlink";       }      but as you can imagine it isn't working... do you have any idea how that can be fixed? thanks!


Is there any plugin for course management?

I have wordpress site for a school or college. My requirement is I need Classes like (from one class to 8th class) and then classes will have courses/subjects(like physics, Maths etc) and then each course has a file to upload. The teacher will upload the file to a course and then the student will download the file of a course from the front end. The teacher will add classes, courses to classes and can upload the files to the courses. The student can only download the files uploaded for a course. SO Is there any plugin of wordpress to do work for me or I have to write my own? Any help and suggestion? Thanks in advance.


My custom plugin did not create db tables in database

I have created a plugin which will create a table in database on plugin activation. When I enabled the plugin and check the database, there was no new table which I want to create. Here is my plugin file code.               <?php     /*     Plugin Name: wp_course_management     Description: Wordpress plugin for course management for an education site.     Version: 1.0     Author: Ahmad Nawaz     Author URI: http://nawaz-ahmad.blogspot.com     */     ?>     <?php     global $jal_db_version;     $jal_db_version = "1.0";          function jal_install() {        global $wpdb;        global $jal_db_version;             $table_name = $wpdb->prefix . "classes";             $sql = $wpdb->prepare( "CREATE TABLE %s (           id mediumint(9) NOT NULL AUTO_INCREMENT,           time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,           name tinytext NOT NULL,           text text NOT NULL,           url VARCHAR(55) DEFAULT '' NOT NULL,           UNIQUE KEY id (id)         );", $table_name );             require_once(ABSPATH . 'wp-admin/includes/upgrade.php');        dbDelta($sql);             add_option("jal_db_version", $jal_db_version);     }          function jal_install_data() {        global $wpdb;        $welcome_name = "Mr. Wordpress";        $welcome_text = "Congratulations, you just completed the installation!";             $rows_affected = $wpdb->insert( $table_name, array( 'time' => current_time('mysql'), 'name' => $welcome_name, 'text' => $welcome_text ) );     }     register_activation_hook(__FILE__,'jal_install');     register_activation_hook(__FILE__,'jal_install_data');          ?>      What is the problem in my code. Please help.


How to call Wordpress First Image Post or else Attached Image or Default

Can anyone help me develop a wordpress script that [IF] will get first image post and if it doesn't exist it will [ELSE] get first attached (uploaded) image. **Theoretically:** [IF exists]               <img src="<?php echo catch_that_image() ?>" />      [or ELSE]               ID) . '" alt="Main Image" id="mainImage"" />      [or ELSE]               <img src="<?php bloginfo('template_url') ?>/images/default.png" />      **My current code looks like this (UPDATED.. AGAIN)**               <?php        $args = array(      'post_parent' => $post->ID,      'post_type' => 'attachment',      'post_mime_type' => 'image',      'orderby' => 'menu_order',      'order' => 'ASC',      'offset' => '0',      'numberposts' => 1       );      $attachments = get_posts($args);      $images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=' . $post->ID );      if ($attachments) {      foreach ($attachments as $attachment) {      if(wp_attachment_is_image( $attachment->ID )) {      echo 'ID) . '" alt="Main Image" id="mainImage"" />'; }}}             else {      echo ''; }     ?>


How could I write a get_categories_by_year() function?

I need to write **a function to get all the categories for a given year**. Since the creation date of a taxonomy isn't stored in the database, I'm not really sure what to do. My initial thought was to get all posts for a given year and somehow find all categories associated with those posts, but I'm not sure how to do that and it sounds horrifically slow. Perhaps I could just write some SQL but I'm much more well versed in PHP. So again back to the function, I imagine it would like something like:               function get_categories_by_year($year) {      // Do stuff...      return $array_of_categories_in_year;     }      This is actually for a custom taxonomy but since categories are the default hierarchical taxonomy I decided to use it as an example. I'm happy to provide more info on what the output is supposed to look like if it's relevant. Thank's for the help!


WordPress WYSIWYG editor on demand, responsive

I have created a WYSIWYG editor inside of a metabox, and I have loaded it on demand via javasacript. But the WYSIWYG is not responsive, like the default one is. How can I make it responsive? It sits inside of a table, and the table width is set to 100%. As the rows get smaller the WYSIWYG remains the same size but part of the editor becomes hidden. I've tried:               .mceToolbarTop * {     float:left;     }          .mceToolbarTop select {     width:auto!important;     }          .mceToolbarTop option {     float:none;     }      The html is really long, and difficult to format here. Or else i'd paste it. My container holding the WYSIWYG is 80% wide, and the WYSIWYG styles is set to 100%, so I don't know why its not respecting the styles I have set.


Use $wpdb in wordpress theme files

I want to use $wpdb in a theme file, but it doesn't work. My code is bellow:               <?php               $action = $_POST['action'];     $updateRecordsArray = $_POST['recordsArray'];               if ($action == "updatelist") {              $listingCounter = 1;         $column = $_GET['column'];              foreach ($updateRecordsArray as $key=>$value) {              $wpdb->update('wp_postmeta', array('meta_value'=>$column), array('post_id'=>$value, 'meta_key'=>'dbt_text') );         $wpdb->update('wp_posts', array('menu_order'=>$listingCounter), array('ID'=>$value) );              $listingCounter = $listingCounter + 1;                }     }               ?>      I think that $wpdb must be declared global or I must include certain files. Can someone please help me on this?


What plugins do you commonly install on a fresh WordPress install?

I'm looking at finding out what plugins others install most of the time on a fresh WordPress install; the plugins that add value to pretty much any website that is running WordPress. My list of commonly installed plugins on a fresh WP install, in no particular order:   * Contact Form 7 - Use whenever I need a contact form on the site   * Page.ly MultiEdit - Use whenever I need multiple editable regions   * Login LockDown - Always use on public facing website. Helps prevent account brute forcing.   * Register Plus Redux Use whenever the site allows member signup.   * WP-PageNavi Use whenever the site will be displaying pages upon pages of posts. Please answer with your commonly used installed plugins on a fresh WP install.


Guidance with The Loop for CMS

Maybe I'm going about this the wrong way but this is my scenario... I would like to use WordPress as a CMS rather than a blogging platform. I have a website that will have somewhere between 25-50 pages and will not have any posts. I'm looking to develop my own theme which should be fairly easy, however I'm getting a little confused on using The Loop functions. I understand that:               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>      is used for a page that is pulling x number of posts, however in my scenario, I only want to pull the contents of a page rather than x number of posts. Do I need to create custom SQL queries? All of the examples I keep running into are using The Loop for posts. If I'm just using static pages, do I even need to use The Loop? Can I just use the unique URL to pull a page out of the post column of the MySQL database? I hope this is making sense.


Subsites in Multisite installation throwing 404 error on wp-admin in IIS 7

Running into an issue where sub sites of a multisite (fresh installation of 3.9 and no plugins or themes) are throwing 404 error when trying to access the wp-admin section of the sub site. It is running on IIS7.   * http://www.mysite.com/subsite/wp-admin -> Throws 404   * http://www.mysite.com/subsite2/wp-admin -> Throws 404   * http://www.mysite.com/wp-admin -> Works for the main site When we login through http://www.mysite.com/wp-admin and navigate to the sub site then try to log out it also throws a 404. Was using the default web.config, for the re-write rules. But all the sub sites were throwing 404 errors on the css/js files. So, I altered the re-write rules a bit, which you can see below.               <?xml version="1.0" encoding="UTF-8"?>     <configuration>         <system.webServer>             <rewrite>                 <rules>                     <rule name="WordPress Rule 1" stopProcessing="true">                         <match url="^index\.php$" ignoreCase="false" />                         <action type="None" />                     </rule>                     <rule name="WordPress Rule 2" stopProcessing="true">                         <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />                         <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />                     </rule>                     <rule name="WordPress Rule 3" stopProcessing="true">                         <match url="^" ignoreCase="false" />                         <conditions logicalGrouping="MatchAny">                             <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />                             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />                         </conditions>                         <action type="None" />                     </rule>                     <rule name="WordPress Rule 4" stopProcessing="true">                         <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />                         <action type="Rewrite" url=“{R:2}” />                     </rule>                     <rule name="WordPress Rule 5” stopProcessing="true">                         <match url="^([_0-9a-zA-Z-]+/)?(wp-comments-post.*)” ignoreCase="false" />                         <action type="Rewrite" url=“{R:2}” />                     </rule>                     <rule name="WordPress Rule 6” stopProcessing="true">                         <match url="^([_0-9a-zA-Z-]+/)?([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />                         <action type="Rewrite" url="{R:2}" />                     </rule>                     <rule name="WordPress Rule 7” stopProcessing="true">                         <match url="." ignoreCase="false" />                         <action type="Rewrite" url="index.php" />                     </rule>                 </rules>             </rewrite>         </system.webServer>     </configuration>      Am I missing any other re-write rules or need to change? So the subsites do not throw 404 errors when navigating to the /wp-admin page.


Finding actual functions added to hooks and filters

I'm trying to figure out how to find the actual function that's assigned to hooks and filters. I've been looking at other questions asked here and found a couple plugins that are helpful for findings the add_actions and add_filters that show me the callback function name... but I'm having a hard time finding that actual function(s) so I can see what it does. They aren't always in the same file as the add_action or add_filter. I just want to do this so I can wrap my head around the concept of hooks and filters better. So for example, here's an add_action in shortcodes.php on line 335:               add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()      Here's the actual function on line 144, I want to be able to find these easily:               function do_shortcode($content) {         global $shortcode_tags;              if (empty($shortcode_tags) || !is_array($shortcode_tags))             return $content;              $pattern = get_shortcode_regex();         return preg_replace_callback( "/$pattern/s", 'do_shortcode_tag', $content );     }      Any tips?


Can't Display Featured Image in RSS Feed

I'm currently working on a test website on my local server using WordPress version 3.4.2. I've tried various different solutions. Some have included installing various plugins, such as WP RSS Images and Featured Image in RSS. Even tried some of the solutions from the following posts:   * display featured image in RSS feed   * How to grab first image attached to post and display in RSS feed?   * Add a Post Thumbnail to an RSS Feed with custom size Yet, it seems the images aren't being posted to the RSS feeds. Is there another solution that can solve this problem? The RSS feed I'm trying to include images is this link. Any help is appreciated!


Exclude category from get_the_category

I want to exclude a specific category from the loop, here's what I tried: Original code:                   // auto posts by cat         if( $bawmrp_options['auto_posts'] == 'cat' || $bawmrp_options['auto_posts'] == 'both' ):             $cat = get_the_category( $post->ID );             $cat_ids = wp_list_pluck( $cat, 'term_id' );             $args['category'] = implode( ',', $cat_ids );         endif;      My try:                   // auto posts by cat         if( $bawmrp_options['auto_posts'] == 'cat' || $bawmrp_options['auto_posts'] == 'both' ):             $cat = get_the_category( $post->ID );             if ($cat->cat_ID != '68') :                 $cat_ids = wp_list_pluck( $cat, 'term_id' );             endif;             $args['category'] = implode( ',', $cat_ids );         endif;      In my code I tried to exclude the category 68, but actually the best thing would be if the category has children, then it don't enter in the loop, only it's children


Error 404 on Network Admin and others

I have a multisite fresh install in my domain. Subfolder setup. Network Admin on the upper right menu has this link `http://example.com/wp- admin/network/` and returns a 404 error. Other links like 'Add New' have this problem too. I can manually visit `http://example.com/subfolder/wp- admin/network/` and works fine. I'm not good with .htaccess but I think the problem is there; can you check this please:               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^wp-admin$ wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^(wp-(content|admin|includes).*) home/content/70/10156275/html/example.net/subfolder/$1 [L]     RewriteRule ^(.*\.php)$ home/content/70/10156275/html/example.com/subfolder/$1 [L]     RewriteRule . index.php [L]      Also, not sure if this helps but my `wp-config.php` has this code:               /* Multisite */     define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', true );     $base = '/';     define( 'DOMAIN_CURRENT_SITE', 'example.com' );     define( 'PATH_CURRENT_SITE', '/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      I have been searching Google for 2 days now and can't fix this… The problem is the subfolder is somewhat omitted in Network Admin and some few…


Get attachments (get_posts) and WP 3.5 new uploader

I'm using get_posts() to get attachments from the post and use it in the slider. The issue is new uploader doesn't have that "Gallery" tab which was perfectly suitable for this. It also seems to be breaking original code and you can't remove / reorder images from this new uploader now. Is there a way to fix this? The code is below:
                  <?php if ( have_posts() ) : while ( have_posts() ) : the_post();                       $args = array(                     'post_type' => 'attachment',                     'numberposts' => -1,                     'post_status' => null,                     'post_parent' => $post->ID,                     'order'=> 'ASC',                      'orderby' => 'menu_order'                    );                              $attachments = get_posts( $args );                       if ( $attachments ) {                          foreach ( $attachments as $attachment ) {                             echo '
';                             echo wp_get_attachment_image( $attachment->ID, 'full' );                             echo '
';                            }                       }                   endwhile; endif; ?>


Embed Wordpress Admin in an iframe

I am trying to embed the admin "new post" wordpress page into an iframe:               `<iframe height="500px" frameborder="0" width="740px" src="my_wordpress_domain/wp-admin/post-new.php"/>`      For some reason the iframe loads a blank page. The link itself works in a separate tab and so does the wordpress home page. Is this a security issue, if so, how can I circumvent it?


Differentiate Between Parent & Child Categories

So I'm working with a non-wordpress theme called "Misty" and it uses this code to pull categories:

<?php _e('Categories','ml'); ?>

             <?php             if (function_exists('wp_list_categories'))             {                 wp_list_categories("show_count=1&include=$catID&hierarchical=1&title_li=");                 wp_list_categories("show_count=1&child_of=$catID&hierarchical=1&title_li=");             }             else             {                 wp_list_cats('optioncount=1');             }             ?>

      What sucks is that I cant style parent / child categories different, I want to indent child categories but they all go by class=category ID `$catID` is how I want to filter posts. 3 different domains are coming to this blog and I am taking where they came from and filtering posts that way. So far I've filtered the category and showed that categories sub-categories, but the subcategories have no way to be styled. What's a good work around to style the child categories? Is there somewhere I can just add another class to the child LI's?


How to use one git (github) repository for version control for multiple themes

I have built and maintain many themes for various clients. I'd like to be able to put them all in github for lovely version control. However github gets a bit expensive when you have over 20 private repositories. I'm going to have about 30+. The themes are not used together, each one is for a separate client. I know I can host my own git install, but then I lose the great diff tools and social aspects of github. It's also nice to have all your code in one place. So I'm wondering if there is another way to put all themes in one repo and separate them in some intelligent way. I thought about using gitignore, but then for each clone, you need to reconstruct the correct .gitignore. not workable. Maybe using branches is the right approach, but I'm unfamiliar with how that would work. One other aspect, I've been using deployhq.com (a great service) to deploy the changed files via ftp to the servers. And it's working great. And for site still in development I create a git service hook and after each push, the project gets deployed automatically by deployhq - awesome. Any advice about how to accomplish this via branches, or via any other method?


Can this site be built using wordpress?

I want to know if this site can be built with wordpress, I'm a programmer and I don't know anything about wordpress, how I'm just to get some good advices from you guys: The main aim of the site is to allow users to view several places of interest in a country Administrator: -create a place of interest - add,delete,edit details such as place name, address, location with google map,rating(users can vote a place),latitude, longitude -add reviews for place on interest Users: -allow users to register -contribute to site by adding a place of interest with all its details(will then be approved by the administator) -add reviews to a place of interest -up vote or downvote a place of interest


register_deactivation_hook argument -> pass arguments in the selected function

I've been looking for minutes how to pass arguments in the `register_deactivation_hook` as follow :               register_deactivation_hook( __FILE__, array( new Cpt, 'delete_cpt') ) );          class Cpt     {         /**          * Delete a custom post type          */         public function delete_cpt($name = 'test') {             /**              * delete a single data              */             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );             $GLOBALS['wpdb']->delete(                  'cpt',                  array(                      'name'=>$name                  )              );             $GLOBALS['wpdb']->show_errors();             echo $GLOBALS['wpdb']->last_query;             echo $name;             die();         }     }      The function executes but the `$name` var remains empty. I would like to pass the `$name` directly in `register_deactivation_hook`; Is it at least possible ? Nothing seen anywhere.


How to post images on my blog with a pre-defined border

The images in this blog post: http://wordfruit.com/blog/the-hole-through-the- earth-3/ ...have borders around them -- hatched lines. But in this post: http://wordfruit.com/blog/copywriting-for-fish/ there's no border around the image. The images in the first example above I think I posted using the 'From url' function. In the second example listed, I used the 'upload' function when posting the image. Is there a way of posting images using the 'upload' function so that the border appears?


Pagination on custom taxonomy

I'm having a tough time getting this to work. It's not the first time I run into problems with pagination, or I would say with WPs URL system. Basically I have this URL:               http://example.com/location/dc       and loads up the `taxonomy-location.php` template. Now, I'm adding the pagination feature to the theme. So I have this URL:               http://example.com/location/dc/page/2      and it won't load the `taxonomy-location.php` template, it actually loads the **404** template. This is what the debug bar shows: > ![http://cl.ly/1u0F470k062o1Q121u15](http://i.stack.imgur.com/vuhdM.png) It seems like it's getting the right values, WP is just not loading up the correct template. * * * **EDIT** (Moved over from the comment links) ## `functions.php`               /* LOCATION */     add_rewrite_rule( 'location/([^/]+)/page/([0-9]{1,})/?$', 'index.php?location=$matches[1]&paged=$matches[2]', 'top' );      ## `taxonomy-location.php`                 <?php        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;       query_posts($query_string.'&posts_per_page=2&paged='.$paged);       ?>
"<?= ucwords(get_query_var('location')); ?>" Venues
            <?php if (have_posts()) : ?>              <?php while (have_posts()) : the_post(); ?>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
         <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('venue_thumb'); ?>
            <?php endwhile; ?>              <?php wp_pagenavi(); ?>            <?php else : ?>

No posts found

          <?php endif; ?>


A featured page with image and excerpt instead of a featured post?

Is there a way to have a link with a featured image and excerpt that goes to another page in Wordpress rather than a featured post? At this moment I have a page that links of to three featured categories but I'd or rather the client would like one of those three preview boxes to link to a featured page and when that page is updated the preview image of that page and an excerpt would be updated on the front page (that holds the box links to the two featured cats and one featured page). _I don't have the site online but I can post a screen shot if I'm not explaining it very well._ Thanks


How to have a category not show up in query post with page panigation?

Basically I have this loop that shows all post. Inside of it I want to exclude post's from categories including shirts and hoodies, also the gallery category. Here is what I have so far. the code works without the 'cat=-gallery". But with it, it does not show any post's at all.               <?php     $limit = 5;     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     query_posts( 'cat=-gallery&showposts=' . $limit . '&paged=' . $paged );     $wp_query->is_category = true; $wp_query->is_home = false;     ?>           <-----my blog stuff---->          <?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
         <?php endif; ?>         <?php next_posts_link('Older Entries »', 0); ?>