February 21, 2014

WordPress Plugin – Injection Guard

Injection Guard

February 12, 2014

PHP Helper Function: get_function_static()

PHP Helper Function: get_function_static() Description: This function returns the name of calling function. You can specify the $index param to retrieve nth level of calling functions. function get_function_static($bt, $index=0) { if (isset($bt[$index][‘function’])) return $bt[$index][‘function’]; else return false; } Usage $bt = debug_backtrace(); $parent_function = $this->get_function_static($bt, 1);

February 1, 2014

Severity: 4096, Object of class stdClass could not be converted to string

Severity: 4096, Object of class stdClass could not be converted to string Error Description: A PHP Error was encountered Severity: 4096 Message: Object of class stdClass could not be converted to string Filename: libraries/Parser.php Line Number: 101 Solution: if (is_array($val)) { $template = $this->_parse_pair($key, $val, $template); } elseif(is_object($val)){ $val = (array)$val; $template = $this->_parse_pair($key, $val, […]

WordPress Widget – RSS Feed Widget

RSS Feed Widget

January 31, 2014

PHP Regular Expressions to Extract Images from HTML Content

PHP Regular Expressions to Extract Images from HTML Content //preg_match_all(‘/<img[^>]+>/i’, $description, $img); //preg_match_all(‘/src=”([^”]*)”/’, $description, $img); preg_match_all(‘@<img.*src=”([^”]*)”[^>/]*/?>@Ui’, $description, $img);

December 31, 2013

WordPress Stickers & Badges Story

WordPress Stickers & Badges Story Its an interesting story that how i got engaged in WP10 party hosting. When i recall that moment i can’t believe that i was just visiting wordpress.org to view my plugin’s stats. I saw a red label on top of the wordpress website. It was exciting to register via meetup.com. […]

December 27, 2013

PHP – Helper Function – clean_xhtml

PHP – Helper Function – clean_xhtml if ( ! function_exists(‘clean_xhtml’)) { function clean_xhtml($string) { /*$string = preg_replace(‘@<iframe[^>]*?>.*?@siu’, ”,html_entity_decode($string)); $string = preg_replace(‘@<p[^>]*?>.*? @siu’, ”,$string); return $string;*/ $string = ereg_replace(“<[^>]*>”, “”, $string); $string = preg_replace(“@<p[^>]*?>.*? @siu”, ”,$string); return $string; } }

December 20, 2013

WordPress Custom Taxonomy Example

WordPress Custom Taxonomy Example: $_tType = ‘Taxonomy Type’; $_tSlug = ‘wp-taxonomy-type’; $_tId = str_replace(‘ ‘, ‘_’, strtolower($_tType)); register_taxonomy($_tId, ‘post’, array( ‘hierarchical’ => true, ‘labels’ => array( ‘name’ => _x( $_tType, ‘taxonomy general name’ ), ‘singular_name’ => _x( $_tType, ‘taxonomy singular name’ ), ‘search_items’ =>  __( ‘Search ‘.$_tType ), ‘all_items’ => __( ‘All ‘.$_tType ), ‘parent_item’ […]