Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MotoPress Visual Controls Example
<?php
/*
Plugin Name: MotoPress Visual Controls Example
Plugin URI: http://www.getmotopress.com/
Description: Example of the visual controls for object
Version: 1.0
Author: MotoPress
Author URI: http://www.getmotopress.com/
*/
// add action to work with MotoPress Library
add_action('mp_library', 'mp_library_visual_controls_example', 10, 1);
function mp_library_visual_controls_example($motopressCELibrary) {
$list = array(
'lorem' => 'Lorem',
'ipsum' => 'Ipsum',
'dolor' => 'Dolor',
);
// create new object
$fooObj = new MPCEObject('foo_obj', __('Foo Object', 'domain'), null, array(
'text' => array(
'type' => 'text',
'label' => __('text', 'domain'),
),
'longtext' => array(
'type' => 'longtext',
'label' => __('longtext', 'domain'),
),
'longtext64' => array(
'type' => 'longtext64',
'label' => __('longtext64', 'domain'),
),
'content' => array(
'type' => 'longtext-tinymce',
'label' => __('longtext-tinymce', 'domain'),
'text' => __('Edit', 'domain'),
'saveInContent' => 'true',
),
'image' => array(
'type' => 'image',
'label' => __('image', 'domain'),
),
'multiimages' => array(
'type' => 'multi-images',
'label' => __('multi-images', 'domain'),
'text' => __('Edit', 'domain'),
),
'video' => array(
'type' => 'video',
'label' => __('video', 'domain'),
),
'mediavideo' => array(
'type' => 'media-video',
'label' => __('media-video', 'domain'),
),
'media' => array(
'type' => 'media',
'label' => __('media', 'domain'),
),
'link' => array(
'type' => 'link',
'label' => __('link', 'domain'),
),
'select' => array(
'type' => 'select',
'label' => __('select', 'domain'),
'list' => $list,
),
'selectmultiple' => array(
'type' => 'select-multiple',
'label' => __('select-multiple', 'domain'),
'list' => $list,
),
'colorselect' => array(
'type' => 'color-select',
'label' => __('color-select', 'domain'),
'list' => $list,
),
'colorpicker' => array(
'type' => 'color-picker',
'label' => __('color-picker', 'domain'),
'list' => $list,
),
'checkbox' => array(
'type' => 'checkbox',
'label' => __('checkbox', 'domain'),
),
'spinner' => array(
'type' => 'spinner',
'label' => __('spinner', 'domain'),
'default' => 500,
'min' => 100,
'max' => 1000,
'step' => 100,
),
'slider' => array(
'type' => 'slider',
'label' => __('slider', 'domain'),
'default' => 500,
'min' => 100,
'max' => 1000,
'step' => 100,
),
'radiobuttons' => array(
'type' => 'radio-buttons',
'label' => __('radio-buttons', 'domain'),
'list' => $list,
),
), 0, MPCEObject::ENCLOSED);
$motopressCELibrary->addObject($fooObj);
}
add_shortcode('foo_obj', 'foo_obj_foo');
function foo_obj_foo($atts, $content = null) {
$result = '<table cellpadding="10" border="1">';
foreach ($atts as $att_id => $att_value) {
$result .= '<tr><td>' . $att_id . '</td>' . '<td>' . $att_value . '</td></tr>';
}
$result .= '<tr><td>$content</td>' . '<td>' . $content . '</td></tr>';
$result .= '</table>';
return '<div>' . $result . '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.