Hot answers tagged wpse-plugin
63
Well what a coincidence that you ask this, Jan! Just today I had time on a long train journey and decided to write a Rewrite Analyzer plugin, one that parses your rewrite rules and highlights the query variables. You can test URLs right there and see what query variables will be set.
You can find it in the plugin repository, or just as Monkeyman Rewrite ...
11
I wrote a shortcode function based on "Twitter Hash Tag Widget" plugin
just copy this function to your themes functions.php file
function tweets_by_hashtag_9867($atts, $content = null){
extract(shortcode_atts(array(
"hashtag" => 'default_tag',
"number" => 5,
), $atts));
$api_url = ...
11
If you add your item into the menu by adding it to the $submenu array directly you'll avoid the need to do the redirect and be able to use a complete offsite URL as the menu link (i do this myself).
add_action( 'admin_menu' , 'admin_menu_new_items' );
function admin_menu_new_items() {
global $submenu;
$submenu['index.php'][500] = array( 'Menu item ...
7
Hi @Tom,
If I understand your question correctly you don't so much need to know how to add a link to the menu (it seems you already know that) but instead need to learn how to get your link to redirect correctly, right?
Redirecting to an External URL from an Admin Menu Item
If so what you need to do is to not use the menu item function but instead "hook" ...
6
I had coded something like this a while back and i remember wanting to upload it to the plugin repository but never had the time, Basically it adds a meta box to the post or page edit screen and lets the user select specific users by name or roles and then it check using the_content filter, so here you go:
Update:
It just got approved in to WordPress ...
6
After reading this thread I saw that I might need this also sometimes. So here is the result:
The internal link checker plugin
It adds a meta box at your post edit screens that shows links to all posts who link internally to the currently displayed post. If you want to alter the output (add something for eg.), please use the provided filter. An example of ...
4
You could also write your own simple get_template_part alias function:
The following allows 3 subfolders for template parts that sit in a theme root folder named devices.
<?php
// STYLESHEETS
function print_device_styles( $client = 'desktop' )
{
$client = apply_filters( 'set_theme_client', $client );
wp_enqueue_style( ...
4
It looks for me that you are adding this event only when there is no such event 'send_email_alerts_hook' scheduled yet. Try something like this and let me know if it workded.
function shedule_email_alerts() {
if ( !wp_next_scheduled( 'send_email_alerts_hook' ) ) {
wp_schedule_event(time(), 'daily', 'send_email_alerts_hook');
} else {
...
2
There's really no documentation for it yet, but you'll probably be able to do it hooking to the attachment_fields_to_save filter and inserting the default caption there.
From the Codex:
attachment_fields_to_save
applied to fields associated with an
attachment prior to saving them in the database. Called in the
media_upload_form_handler function. ...
1
Ok, I could solve the problem by using wp_clear_scheduled_hook()
I commented out my schedule declaration and added wp_clear_scheduled_hook('send_email_alerts_hook') at the end. Then deactivate - reactivate my plugin, which removed my scheduled hook. Then removed wp_clear_scheduled_hook() and uncommented my code, now the schedule was set properly.
Found the ...
1
There is no separate table or data structure that keeps post-to-post links, so the best way to do this is to search your posts for the URL of the post you want to delete. The search works on the HTML code of the post, so it will contain the full link, even if you don't see it in the visual editor.
Of course, you should also search through the pages, since ...
1
In addidtion to what One Trick Pony wrote, if the site owner needs the ability to restrict the content to each user, you can develop a small custom meta box that will appear inside each post and will display checkboxes with the site's users and then you will have in your dayabse the needed post_meta of the users that have permission to the content and you ...
1
Assuming this content is the usual post loop:
$current_user = wp_get_current_user();
if(get_the_author_meta('ID') === $current_user->ID):
// show the content
endif;
I think this only works inside the loop.
If you need it outside the loop then just query posts from $current_user->ID:
$query = new WP_Query('author' => $current_user->ID);
1
Generally Plugins and Themes have the same possiblities. But at some points, there's a big difference. Themes come later and therefore have less power. Plus: a lot of functions only work for plugins.
What you're trying to do is modifying core-behavior. In some places core offers hooks to even completely exchange parts of it and in others it offers hooks to ...
Only top voted, non community-wiki answers of a minimum length are eligible