Remove „Private:“ from the titles of private WordPress pages

# add to functions.php of your theme
function the_title_trim($title) {
  $title = attribute_escape($title);
  $findthese = array( '#Protected:#', '#Private:#' );
  $replacewith = array( '', // What to replace "Protected:" with '' //What to replace "Private:" with );
  $title = preg_replace($findthese, $replacewith, $title);

  return $title;
}
add_filter('the_title', 'the_title_trim');

Quoted of the Web: „PHPs badness is its advantage“

I love Python, I think JavaScript is sort of OK and I did a lot of serious programming in ActionScript 2&3, both of which are quite simular to JS. I was basically forced into doing PHP by the market. I never really liked PHP but I really never hated it either. The thing about PHP is that it’s so specific in its domain and such a hack that no one doing PHP development for a living will go around boasting about the greatness of the language. There is a refreshing lack of arrogance in the PHP community which, in my observation, makes it very easy for n00bs to pick up. As a result we get countless people reinventing the wheel in PHP and discovering basic programming patters anew for them selves and starting yet another Framework/CMS/Whatnot and the results often are really bizar. But the community remains alive that way.

Working with Drupal with a current project because it’s the prime go-to CMS here is like a live alice in wonderland trip. A strange historically grown mess, barely tamed by sanitiy and a relentless chaotic community that all by accident seem to come up with hacks that somehow solve the problem in some way. And yet there’s a solid global corporation building its business all around Drupal [acquia.com]. The surreal hacks with which the Drupal people solve their problems are mindboggling, and yet everybody seems totally OK with it. And Drupals track record of deployments is impressive.

I guess with PHP it’s somehow like the C vs. Lisp argument: C is so shitty compared to Lisp that you have to get yourself together and work as a team, or you won’t get anything done. Hence Lisp has this loner exisitance on the side and all the real work gets done in this ancient C thing.

PHP is a simular thing. It is so bad that no respectable programmer would pick it up voluntarly nowadays, but yet it grew out of Perl (which is worse in some ways), was somewhat of an improvement and was at the right place at the right time. The badness of PHP accounts for its considerable lack of arrogance (compare the PHP community to the Ruby community for instance) and for no one feeling guilty when he does a quick bad hack.

As a programmer you don’t feel dirty when you do bad programming in PHP, you already felt that when you picked PHP as the solution. Hence quite a bit of work gets done in PHP. That’s why PHP has Drupal and Typo3 and Joomla and the Java Community has nothing of that proportions. The barrier of entry into PHP is *very* low which gives it its momentum.

WordPress Path to actual active theme / Pfad zum eigentlich aktiven Theme

preg_replace("/\/\w*?\.css/", "/", get_stylesheet_uri());

Gibt den Pfad des aktiven Themes zurück, auch wenn dies ein Child-Theme ist. Vorrausgesetzt, das Child Stylesheet ist mit WordPress Bordmitteln im Theme eingebunden und aktiviert.

Returns the path of the actual active theme, even if this is a child theme. This only works if the child themes stylesheet is included with WordPress methods.

Return value comes with trailing Slash!!

URLs in WordPress

site_url();
bloginfo("wpurl"); //check this!

Returns Root Domain URL without trailing slash.


home_url();

Returns URL of the WordPress Home target without trailing slash. Usually is the same as the root domain, but needn’t be!


admin_url();

Returns the URL leading to the WP Admin directory including trailing slash. URLs in WordPress weiterlesen

Letztes URL Element mit Inhalt / Last URL Segment with content

array_pop(array_filter(explode("/", $_SERVER['REQUEST_URI']), function ($val){return (strlen($val) > 0);}));

(Das ist PHP / This is PHP)


is_int($thisValue = array_pop(array_filter(explode("/", $_SERVER['REQUEST_URI']), function ($val){return (strlen($val) > 0);}))) ? $thisValue : false;

This command only returns a value if the snippet retrieved is an Integer (better for grabbing IDs) – otherwise it returns false / Dieser Befehl gibt den Wert nur zurück, falls das URL Snippet einen Integerwert enthält – ansonsten wird der Wert „false“ zurückgeben (praktisch um IDs abzugreifen)