Extending WP’s upload/insert media functionality

Both of these are possible. Insert Attachment into Media Library By using the wp_insert_attachment function, you can insert your uploaded images to the Media Library. This is the example code from the Docs: <?php $wp_filetype = wp_check_filetype(basename($filename), null ); $wp_upload_dir = wp_upload_dir(); $attachment = array( ‘guid’ => $wp_upload_dir[‘baseurl’] . _wp_relative_upload_path( $filename ), ‘post_mime_type’ => $wp_filetype[‘type’], … Read more

Travel Blog Plugins

I think GeoMashup is the go-to plugin for something like this. http://wordpress.org/extend/plugins/geo-mashup/ I’ve used it for a similar site with great results. There’s a lot to dig into, it’s very flexible, but you’ll definitely be able to get what you want.

Setting up widgets in wordpress with a unique ID for the after_title argument

Looking at widget.php in trac sprintf() only runs on before_widget (Line 884): $params[0][‘before_widget’] = sprintf($params[0][‘before_widget’], $id, $classname_); Hence, it won’t work for any of the other arguments. I wondered whether you could use the dynamic_sidebar_params filter, but the $id and $classname_ arguments aren’t passed on to the filter. Outside of hacking core, I’m not sure … Read more

How do I register a stylesheet inside a WordPress widget?

wp_enqueue_scripts is called way before WordPress processes the widget content, so just as in this post, you’ve missed the boat :). Instead, just call wp_enqueue_style directly: function widget($args, $instance) { wp_enqueue_style( ‘myprefix-style’, plugins_url(‘mystyle.css’, __FILE__) ); //Widget content } (no need to register if you’re just going to enqueue it straight after). Same works for wp_enqueue_script.

How to use get_categories() with Event Organiser plugin

Event categories are terms in a custom taxonomy, ‘event-category’, so you should use get_terms instead: //Args for which terms to retrieve $args = array(‘type’=> ‘post’, ‘order’ => ‘ASC’, ‘hide_empty’ => 1 ); //Array of taxonomies from which to collect the terms $taxonomies = array(‘event-category’); //Get the terms $terms = get_terms( $taxonomies, $args); //loop through the … Read more

I need to generate the CSS for my plugin from a function, how do i map a request to a function in the front-end?

This is forked from something I wrote for a similar requirement. empty( $_GET[‘my-css-var’] ) || add_action( ‘plugins_loaded’, ‘wpse_59089_css’ ); function wpse_59089_css() { header( ‘Content-Type: text/css’ ); // Aggressive caching to save future requests from the same client. $etag = ‘”‘ . md5( __FILE__ . $_GET[‘my-css-var’] ) . ‘”‘; header( ‘ETag: ‘ . $etag ); header( … Read more

How do I make a wordpress plugin with menu item etc

If you want a frontend page you’ll have to create one with your plugin’s shortcode as the content. Then you display your plugin’s output in-place of that shortcode: /* Plugin Name: WPSE67438 Page plugin */ class wpse67438_plugin { const PAGE_TITLE = ‘WPSE67438’; //set the page title here. const SHORTCODE = ‘WPSE67438’; //set custom shortcode here. … Read more