Hot answers tagged api
16
There are two types of rewrite rules in WordPress: internal rules (stored in the database and parsed by WP::parse_request()), and external rules (stored in .htaccess and parsed by Apache). You can choose either way, depending on how much of WordPress you need in your called file.
The external rule is the easiest to set up and to follow. It will execute ...
13
if you look at the do_settings_sections function more specifically the line 1164 where the callback function is being executed :
call_user_func($section['callback'], $section);
you can see that the $section array is being passed to the callback function, so you can identify the callback by the $section['id']
hope this make since.
Update
here is an ...
12
WordPress expects the $_SERVER variables to be setup as if it were a normal web request. Also, I would suggest loading wp-load.php instead of wp-blog-header.php since you probably don't need the WP class or the template loader to run. Here is how I normally start any scripts I need to interact with WP from command line:
define('DOING_AJAX', true);
...
12
I might be misunderstanding you, but why not use wp_create_nav_menu()?
E.g., this is what I do to create a custom BuddyPress menu when I detect BP as active:
$menuname = $lblg_themename . ' BuddyPress Menu';
$bpmenulocation = 'lblgbpmenu';
// Does the menu exist already?
$menu_exists = wp_get_nav_menu_object( $menuname );
// If it doesn't exist, let's ...
12
The API you offer in a plugin or a theme depends on the logic of that specific code. There is probably no guide that applies to all situations.
I am a contributor for multiple plugins with APIs, and what I have learned so far is:
Do not offer an API until you really know how people use your code.
Release the first two or three versions without any API. ...
11
Hi @Sruly:
You've pretty much answered your own question, but I'll elaborate a bit.
Action Hooks
Actions Hooks are intended for use when WordPress core or some plugin or theme is giving you the opportunity to insert your code at a certain point and do one or more of the following:
Use echo to inject some HTML or other content into the response buffer,
...
9
There's a few bits here that apply, but the short of it is this code in customize-preview.js:
this.body.on( 'click.preview', 'a', function( event ) {
event.preventDefault();
self.send( 'scroll', 0 );
self.send( 'url', $(this).prop('href') );
});
The event.preventDefault prevents the links from actually working. The following code then sends a ...
7
This worked for me. I never ever touch the rewrite API, but am always up to push myself in new directions. The following worked on my test server for 3.0 located in a sub folder of localhost. I don't for see any issue if WordPress is installed in web root.
Just drop this code in a plugin and upload the file named "taco-kittens.php" directly in the plugin ...
7
There is a global variable in wp-admin called $pagenow which holds name of the current page, ie edit.php, post.php, etc.
You can also check the $_GET request to narrow your location down further, for example:
global $pagenow;
if (( $pagenow == 'post.php' ) && ($_GET['post_type'] == 'page')) {
// editing a page
}
if ($pagenow == ...
7
I think the best option is an endpoint. You get all the data as a simple string, so you can decide how it will be parsed, and you don’t have to worry about collisions with other rewrite rules.
One thing I learned about endpoints: keep the main work as abstract as possible, fix the glitches in WordPress’ API in a data agnostic way.
I would separate the ...
6
If you are using PHP 5.2+ you're best bet is to just make a PHP array or object and use json_encode().
UPDATED:
$cats = get_categories();
$output = array('categories' => array());
foreach ($cats as $cat) {
$cat_output = array(
'cat_id' => $cat->term_id,
'cat_name' => $cat->name,
'posts' => array(),
);
...
5
WordPress features a very rich XML-RPC interface that you can work with from external applications. It provides you access to most of the functionality you'd have directly in the admin - write posts, edit posts, edit comments, create/edit categories, manage site options, upload files, etc.
As a matter of fact, certain third-party applications are already ...
5
I'm a little confused by your question, can you not simply use wp_enqueue_style, which you actually wrote into this threads heading(not sure if you know the function exists or not).
wp_enqueue_style works in the same way as the wp_enqueue_script counterpart, but of course as you'd expect, enqueues stylesheets..
Here's a list of the enqueues i was able to ...
5
wp_localize_script() now uses json_encode() which means a multidimensional array will now work for the passed data. And, HTML entity decoding only applies to the first level of the array.
Better is an way to use json and default js possibilities from WP.
At first, i add the options from the database via script and json_encode to wp header:
add_action( ...
4
Let me apologize for the initial question I had about your motives. I see a lot of "how can I remotely retrieve all posts from another blog" questions and immediately assume there is nefarious intent because, 9 times out of 10, there is. That said, your purposes seem very straight-forward and respectable.
Currently, there is no way to "chunk" the XML ...
4
The way to do this is to use the 'admin_enqueue_scripts' hook to en-queue the files you need. This hook will get passed a $hook_suffix that relates to the current page that is loaded:
function my_admin_enqueue($hook_suffix) {
if($hook_suffix == 'appearance_page_theme-options') {
wp_enqueue_script('my-theme-settings', ...
4
Hmmm, can't remember or find fitting function either.
There is wp_set_object_terms() that is used in multiple wrappers like wp_set_post_categories(). It can overwrite categories for a post.
So you can get post categories, check for unwanted one and write it back excluding unwanted in that case.
4
wp_get_active_and_valid_plugins()
get_plugins()
and get_option('active_plugins')
4
Known issue
The only thing were you shouldn't use the class WP_List_Table without checking if it is already in use, is inside a meta box.
Reason
Using it would break the columns of one of the meta boxes as there's only one filter to setup the screen columns per screen.
Filters
manage_{$screen->id}_columns inside get_column_headers()
...
4
WordPpress platform provides XML-RPC support which you can use to maintain your WP site. You also enable to extend functionality of build in xml-rpc methods to use it for your needs.
3
I know this is an old question but I'll throw my two cents in, just in case someone else comes along; a simpler way to do so would be do write you own modification of the add_settings_section() function, which would only add a callback args parameter at the end of it.
This would look like this ( or something like it )
function my_add_settings_section($id, ...
3
Calls from core to api.wordpress.org (wp 3.2.1)
From the phpDoc blocks:
Inside head of wp_update_themes(): "A list of all themes installed in sent to WP."
Themes
/wp-includes/update.php > line 261-267, called on line 280 [1].
Plugins /wp-includes/update.php > line 166-172, called on line 184
Core /wp-includes/update.php > starting on line ...
3
I haven't used Socialite before today, so I did a quick install to see if I could reproduce the problem and ... wow ...
The system is definitely broken.
Facebook requires you to partially host your application on your own server. You set up some integration so you can use its API, but most of the work actually happens off-site. With other ...
3
This is why:
http://plugins.trac.wordpress.org/browser/stats/tags/1.7.2/stats.php#L685
The deactivation hook deletes your database information. I'm guessing you're manually deactivating the plugin, updating, and then re-activating? If so, that runs the deactivation hook. Fortunately, that's not from the latest version. This is:
...
3
The do_settings_section() function call needs to correspond to the $optiongroup argument you pass to register_setting(). To see how all of the myriad functions fit together, see page 10 of my tutorial.
It does get fairly confusing trying to follow how the various functions string together.
EDIT:
You do appear to be using the option group properly. Can you ...
3
Hi @James:
If you have the post ID of your newly created post (the $created variable from your question) you use the wp_set_object_terms() function, for example:
wp_add_post_tags($created,'My First Tag');
wp_add_post_tags($created,'My Second Tag');
wp_add_post_tags($created,'My Third Tag');
3
Use the following function to debug the HTTP API request, you will get to know the actual reason why the HTTP API request is failing.
Paste the following code in your theme's function.php.
function dump_http_response( $response, $type, $transport ) {
if ( is_admin() && $type == "response" ) {
echo '<span style="color: #f00;">';
...
3
The correct "WordPress" way of doing it would be to use the_widget template tag to display widgets anywhere you want.
so in you case you would something like this:
$instance['account'] = 'account name'; //Ustream channel name
$instance['online'] = 'http://www.online_image.URL';
$instance['offline'] = 'http://www.offline_image.URL';
...
3
As a complement to ZaMoose's anwser, here's how you would create a "Page-type" menu item (not a "Custom" one):
wp_update_nav_menu_item($menu_id, 0, array('menu-item-title' => 'About',
'menu-item-object' => 'page',
'menu-item-object-id' => ...
3
No, but it should ;)
There are several custom field class's (backend).
wpAlchemy : https://github.com/farinspace/wpalchemy
Meta Box Script: https://github.com/rilwis/meta-box
My-Meta-Box: https://github.com/bainternet/My-Meta-Box
meta-box-class: https://github.com/corycrowley/meta-box-class
Meta Boxes Class: ...
Only top voted, non community-wiki answers of a minimum length are eligible