Adding an object

To add your shortcode to MotoPress Content Editor interface you need to “describe” it first. To do that, create an instance of MPCEObject like this:

$youShortcodeObj = new MPCEObject( $id, $name, $icon, $attributes, $position, $closeType, $resize );

Object parameters

$id
(string) (required) The $id should match with your shortcode tag name.
Default: None

$name
(string) (required) Specifies the name of the object in the MotoPress Content Editor interface.
Default: None

$icon
(string) (required) path to the object icon within the wp-content folder.
Default: empty string

$attributes
(array) (required) Multidimensional associative array, where keys are your shortcode attributes and values are associated visual controls.

$closeType
(string) (required) It defines enclosing or self-closing shortcode type. The value should be one of these constants:

  • MPCEObject::SELF_CLOSED – if your shortcode is self-closed.
  • MPCEObject::ENCLOSED – if your shortcode is enclosed.

Default: MPCEObject::SELF_CLOSED
Read more about enclosing & self-closing shortcodes.

$position
Position of the object.
Default: 0

$resize
(string) Sets the ability to resize your object. List of the available options:

  • MPCEObject::RESIZE_NONE – doesn’t allow to resize
  • MPCEObject::RESIZE_HORIZONTAL – allows to resize horizontally
  • MPCEObject::RESIZE_VERTICAL – allows to resize vertically
  • MPCEObject::RESIZE_ALL – allows to resize horizontally and vertically

Default: MPCEObject::RESIZE_HORIZONTAL

When your shortcode is completely described you can add it to the one of available groups within the addObject method.


    $motopressCELibrary->addObject($youShortcodeObj, $group = 'other');

List of available groups:

  • text
  • image
  • button
  • media
  • other
  • wordpress

Related Topics

Leave a Reply

Your email address will not be published. Required fields are marked *