Giter Club home page Giter Club logo

pixcodes's Introduction

Build Status

PixCodes Is a WordPress plugin which offers you a nice "Add shortcode" button in your editor which opens a modal with a list of shortcodes to add in editor.

PixCodes is build to be controlled by the theme, we needed a plugin which allows the themes to select which shortcodes they support and provide style for.

So beside having an awesome shortcodes insert interface, PixCodes offers you a way for theme developers to:

  • Select which shortcodes you want.>>>
  • Edit the HTML markup of each shortcode.>>>
  • Add/remove attributes.>>>

Filter shortcodes

The shortcodes list is kept in the database as a Wordpress option under the wpgrade_shortcodes_list.

So if you want to edit the shortcode list you will need to add this to your functions.php or somewhere in your theme:

function edit_pixcodes_shortcodes_list() {
  if ( ! is_admin() ) { //only admins should do this
    return; 
  }
  
  // create an array with the names of the shortcodes you want
  $shortcodes = array(
    'Button',
    'Quote',
    'Icon',
    'Columns',
    'Slider',
    'Tabs'
  );
  update_option( 'wpgrade_shortcodes_list', $shortcodes );
}
add_action( 'admin_head', 'edit_pixcodes_shortcodes_list' );

Now check again the PixCodes modal.

Shortcode Templates

Each shortcode has his own template in the plugin's folder shortcodes/templates the awesome part of this is that you can overwrite them inside your theme.

So if you don't like the html template of the button just copy your shortcode file from pixcodes/shortcodes/templates/button.php into your theme at theme/templates/shortcodes/button.php.

Now anything you put in your theme's file button.php will be outputted when in the editor there will be an [button] shortcode.

Edit shortcode parameters

Each shortcode has(or not) a set of parameters which they will be parsed as attributes in the WordPress editor.

You may want the add or remove some of these params so we offer a way to do it.

Let's say that for the button shortcode you want a new attribute named "Title".

In this case you should use the pixcodes_filter_params_for_{shortcode} filter.

For the button shortcode, you should add this filter to your theme (maybe functions.php)

add_filter('pixcodes_filter_params_for_button', 'pixcodes_edit_button_params', 10, 1);

function pixcodes_edit_button_params( $params ){
  $params['title'] = array(
		'type'        => 'text',
		'name'        => 'Title'
	);
			
	return $params;
}

pixcodes's People

Contributors

cristian-frumusanu avatar andreilupu avatar razwan 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.