Think of objects is critical (and natural) in some programming languages. In Objective-C, for example, there is no thing that can not be designed and molded to objects. In PHP this practice is less common, because the language is a bit recently, object-oriented, a little bit because it does not offer much in terms of OO programming, and a little bit because the same PHP programmers have perhaps fear of burdening or embarking on situations apparently solved by writing code more linear.
Category 'PHP'
WPDK: thinking Object-Oriented
WPDK: coding style
The framework WPDK began as a compendium and development aid on WordPress. It therefore does not want to replace the core, but it needs to deal with the current structure of the code. For a variety of reasons, some understandable and others a little less, WordPress core exposes a sometimes poorly structured. Lacks homogeneity, consistency, both at logic level and at the level of code style.
WPDK: PHP Overloading
The overloading is characteristic of many object-oriented languages can distinguish two or more methods called in an identical manner from the differences of the parameters. Be careful because as indicated in the PHP manual:
PHP's interpretation of "overloading" is different than most object-oriented languages. Overloading traditionally Provides the ability to have multiple methods with the same name but different quantities and types of arguments.
However, if PHP was actually typed and would include overloading, you could write:
WPDK: how I did it
During the development of the system wpXtreme and in particular the development WPDK KIT (WordPress Development Kit), I learned a lot! Above all, I began to appreciate techniques that in the past I used infrequently.
So I want to start with this post to tell you about all the wonderful things that I have learned to love and put into practice, in relation to the development of the framework WPDK dedicated to the development of WordPress.
WPDK WordPress Development Kit
The WPDK (WordPress Development Kit) is a proprietary framework developed to speed up the development of the suite wpXtreme . The use of a framework, in addition to making the creation of plugins for WordPress faster it possible to concentrate in one place many features common to many plugins. The WPDK therefore represents an eproprio SDK for developing plug-ins (and not only), providing APIs and services that can be updated and improved over time.
WordPress folder functions: all paths lead to WordPress
WordPress offers many ways to access the names of its folders and build new ones. Here is a helpful list with examples performed, to be more clear, from a subfolder located in a hypothetical plugin:
Plugins
Let's start with plugins_url() useful to determine and build url when you write a plugin.
plugins_url ()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | / / If this line is performed by / / Http://www.miosito.com/wp-content/plugins/my_plugin/classes/test.php plugins_url ( ) ; $ R = plugins_url (); / / Http://www.miosito.com/wp-content/plugins/ plugins_url ( 'myscript.js' , __FILE__ ) ; $ R = plugins_url ('MyScript.js', __ FILE__); / / Http://www.miosito.com/wp-content/plugins/my_plugin/classes/myscript.js plugins_url ( 'assets' ) ; $ R = plugins_url ('assets'); / / Http://www.miosito.com/wp-content/plugins/assets trailingslashit ( plugins_url ( 'assets' ) ) ; $ R = trailingslashit (plugins_url ('assets')); / / Http://www.miosito.com/wp-content/plugins/assets/ |
WordPress: get_posts () and orderby
negli argomenti passati negli inputs. Using get_posts() , you can select a sequence of exact post using the parameter post__in in the arguments passed in the inputs. . The order, however, is not consistent with the sequence shown as WordPress performs checks on the clause ORDER BY of the select, in spite of version 2.8 is available the value none .
Anonymous Functions
I have been asked what is the advantage or disadvantage in the use of anonymous functions or inline (or onfly), used a lot in Javascript, now with 5.3, also in PHP.
An inline function, or anonymous because he did not - in fact - a name, it is a fast way to write some procedures, indenting tree sequences callback for example. Almost all languages support the functionality of this writing, each to the limit with its peculiarities and restrictions. They may also have different names and syntax details, such as the so-called blocks in Objective-C.
WordPress snippet: extract meta value with get_posts ()
Working with a Custom Post Type ( CPT ) it is natural to use the internal functions of WordPress to view and filter the posts of this kind. , risulta comodissimo poter creare loop personali sulle proprie tipologie di post. Whether you use the get_posts() is that it creates an object directly WP_Query , it's very comfortable to create loops on their own personal types of posts. WordPress also allows you to make filters to tassionomie personal, on the count, order, coming up to the meta data. Very useful, in fact, is the process that allows you to specify where in terms of what kind of meta data and compare it with rules.
Bachi beginning of the year: WordPress and WPML get_page_by_path update ()
The year 2012 began with a few hours of deep-debugging because of two (known) bugs quite annoying. , con la globale (e famosa) omonima istanza $wpdb . The first, inter alia quite dated, present in the core of WordPress that concerns the method update() of class wpdb , with the global (and popular) homonymous instance $wpdb . The fault appears when you try to update a field to NULL . Despite numerous complaints, the WordPress development team seems to find no solution to the annoying problem. In fact, to date, the only solution is to write down the SQL on its own.






Latest Comments
Ludovica : Hello! I'll explain my doubt. When I write a post not add pictures in the article (if so ...
Marco : hello @ Giovan Battista Fazioli, thanks for all the explanations of this excellent guide. I have a question to ...
Roberto : Roberto @: @ Roberto: I was wondering if using [cci] the_post_thumbnail () [/ cc i] to load on the homepage ...
Lorenzo : That's great! Thank you for the usefulness and effectiveness of assistance! I found your blog as ...
Shawn : I have upgraded to a new verison of WP-Bannerize and I ran into some errors. Is there a way to figure out the ...