GithubHelp home page GithubHelp logo

developers81828182 / shortcake Goto Github PK

View Code? Open in Web Editor NEW

This project forked from crstauf/shortcake

0.0 1.0 0.0 389 KB

Shortcake makes using WordPress shortcodes a piece of cake.

Home Page: http://next.fusion.net

License: GNU General Public License v2.0

Shell 3.74% JavaScript 48.11% PHP 36.91% CSS 11.24%

shortcake's Introduction

Shortcake

Shortcake makes WordPress shortcodes a piece of cake.

Used alongside add_shortcode, Shortcake supplies a user-friendly interface for adding a shortcode to a post, and viewing and editing it from within the content editor.

See:

Usage

add_action( 'init', function() {

	/**
	 * Register your shortcode as you would normally.
	 * This is a simple example for a pullquote with a citation.
	 */
	add_shortcode( 'pullquote', function( $attr, $content = '' ) {

		$attr = wp_parse_args( $attr, array(
			'source' => ''
		) );

		ob_start();

		?>

		<section class="pullquote">
			<?php echo esc_html( $content ); ?><br/>
			<cite><em><?php echo esc_html( $attr['source'] ); ?></em></cite>
		</section>

		<?php

		return ob_get_clean();
	} );

	/**
	 * Register a UI for the Shortcode.
	 * Pass the shortcode tag (string)
	 * and an array or args.
	 */
	shortcode_ui_register_for_shortcode(
		'pullquote',
		array(

			// Display label. String. Required.
			'label' => 'Pullquote',

			// Icon/image for shortcode. Optional. src or dashicons-$icon. Defaults to carrot.
			'listItemImage' => 'dashicons-editor-quote',

			// Available shortcode attributes and default values. Required. Array.
			// Attribute model expects 'attr', 'type' and 'label'
			// Supported field types: text, checkbox, textarea, radio, select, email, url, number, and date.
			'attrs' => array(
				array(
					'label' => 'Quote',
					'attr'  => 'content',
					'type'  => 'textarea',
				),
				array(
					'label'       => 'Cite',
					'attr'        => 'source',
					'type'        => 'text',
					'placeholder' => 'Firstname Lastname',
				),
			),
		)
	);

} );

Install the demo plugin using this snippet

Examples

Screenshots

Without Shortcake, shortcodes have a minimal UI. no-shortcake

But with Shortcake, TinyMCE will render the shortcode in a TinyMCE view. shortcake

And add a user-friendly UI to edit shortcode content and attributes. screen shot 2014-11-10 at 1 48 29 pm

Known issues

  • You cannot use camelcase or hyphens in attribute names.
  • If your shortcode output is not a block level element, it may display oddly in the TinyMCE editor.

shortcake's People

Contributors

mattheu avatar danielbachhuber avatar zebulonj avatar davisshaver avatar dbarlett avatar roborourke avatar thomasmb avatar jitendraharpalani58 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.