Skip to content

Instantly share code, notes, and snippets.

@rubencosta
Last active December 11, 2015 09:42
Show Gist options
  • Save rubencosta/c28a226b44bf036304a5 to your computer and use it in GitHub Desktop.
Save rubencosta/c28a226b44bf036304a5 to your computer and use it in GitHub Desktop.
WORDPRESS LEARNINGS

WORDPRESS LEARNINGS

Global References

Writing a plugin

Javascript

Modal

Render default modal

// Create a modal view.
var modal = new wp.media.view.Modal({
	// A controller object is expected, but let's just pass
	// a fake one to illustrate this proof of concept without
	// getting console errors.
	controller: { trigger: function() {} }
});
// Create a modal content view.
var ModalContentView = wp.Backbone.View.extend({
	template: wp.template( 'modal-content' )
});

// When the user clicks a button, open a modal.
$('.js--open-media-modal').click( function( event ) {
	event.preventDefault();
	// Assign the ModalContentView to the modal as the `content` subview.
	// Proxies to View.views.set( '.media-modal-content', content );
	modal.content( new ModalContentView() );
	// Out of the box, the modal is closed, so we need to open() it.
	modal.open();
});

Adding add petition button to the WP content editor

Add media button

http://www.sitepoint.com/adding-a-media-button-to-the-content-editor/

add_action('media_buttons', array($this, self::PAGE_SLUG . '_media_button'));
public function Nublico_media_button()
{
    echo '<button type="button" id="nublico-media-button" class="button">Add nublico Petition</button>';
}

Render petition

inside a post/page

https://codex.wordpress.org/Shortcode_API

inside WP content editor

https://github.com/bainternet/bs3_panel_shortcode/ https://lkwdwrd.com/wp-shortcode-wp-html-wordpress-shortcodes-javascript/

Interesting hooks

 add_action ( 'publish_post', [function name] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment