"Category","product"=>"Product","inapp"=>"In-App Page","wlink"=>"WebView link","elink"=>"External link","title"=>"Title");
/**
* Field Constructor.
*
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
* @since Redux_Options 2.0.1
*/
function __construct($field = array(), $value = '', $parent)
{
// parent::__construct( $parent->sections, $parent->args );
$this->parent = $parent;
$this->field = $field;
$this->value = $value;
include_once(ReduxFramework::$_dir. "inc/fields/media/field_media.php");
$this->widget_handler = new widget_handler($this->field,$this->value,$this->parent);
$this->media_field = new ReduxFramework_media(array(
'id' => $this->field['id'],
'class' => 'opt-media',
'name' => $this->field['id'],
'name_suffix' => '',
'type' => 'media',
'width' => '100',
'height' => '100',
'url' => false,
'title' => __('Media w/ URL', 'redux-framework-demo'),
'desc' => __('Basic media uploader with disabled URL input field.', 'redux-framework-demo'),
'subtitle' => __('Upload any media using the WordPress native uploader', 'redux-framework-demo'),
),'',$this->parent);
$this->media_field->enqueue();
}
function getType($key){
return isset($this->types[$key])?$this->types[$key]:'';
}
function items(){
?>
Menu Items
Add required menu items to navigation menu
'product_cat',
'orderby' => 'id',
'show_count' => true,
'pad_counts' => true,
'hierarchical' => true,
'title_li' => '',
'hide_empty' => false
);
$catTerms = get_categories($args);
$sortable = array();
foreach($catTerms as $cat){
$sortable[] = array(
'id'=> 'cat_'.$cat->term_id,
'parent'=>'cat_'.$cat->parent,
'label' => $cat->cat_name,
'label_value' => $cat->cat_name,
'type' => 'cat',
'value' => $cat->term_id,
'taxonomy'=>$cat->taxonomy
);
}
return $sortable;
}
/**
* Field Render Function.
*
* Takes the vars and outputs the HTML for the field in the settings
*
* @since Redux_Options 2.0.1
*/
function render()
{
if(isset($this->field['doc']))
echo $this->field['doc'];
?>
|
|
";
foreach ($array as $item) {
if (is_array($item) && isset($item['id'])) {
$display_options = $item;
unset($display_options['parent']);
unset($display_options['childNodes']);
if (isset($item['childNodes']) && is_array($item['childNodes']) && !empty($item['childNodes'])) {
echo "\n\n".$item['label'] ."
";
// echo '
';
if(isset($item['media_id']) && isset($item['media_url']) && !empty($item['media_url']) &&!empty($item['media_id']))
{
echo '

';
echo '
';
}
echo '
';
$dis_val = (isset($item['label_value']))?$item['label_value']:$item['value'];
echo '
'.$dis_val.' ('.$this->getType($item['type']).') Delete ';
echo "
";
$this->printMenu($item['childNodes'],false);
echo "\n\n";
} else {
echo "\n\n".$item['label'] ."
";
//echo '
if(isset($item['media_id']) && isset($item['media_url']) && !empty($item['media_url']) &&!empty($item['media_id']))
{
echo '

';
echo '
';
}
echo '
';
$dis_val = (isset($item['label_value']) && !empty($item['label_value']))?$item['label_value']:$item['value'];
echo '
'.$dis_val.' ('.$this->getType($item['type']).') Delete ';
echo "
\n\n";
}
}
}
echo "\n";
}
public static function convertToHierarchy($results, $idField='id', $parentIdField='parent', $childrenField='childNodes') {
$hierarchy = array(); // -- Stores the final data
$itemReferences = array(); // -- temporary array, storing references to all items in a single-dimention
foreach ( $results as $item ) {
$id = $item[$idField];
$parentId = $item[$parentIdField];
if (isset($itemReferences[$parentId])) { // parent exists
$itemReferences[$parentId][$childrenField][$id] = $item; // assign item to parent
$itemReferences[$id] =& $itemReferences[$parentId][$childrenField][$id]; // reference parent's item in single-dimentional array
} elseif (!$parentId || !isset($hierarchy[$parentId])) { // -- parent Id empty or does not exist. Add it to the root
$hierarchy[$id] = $item;
$itemReferences[$id] =& $hierarchy[$id];
}
}
unset($results, $item, $id, $parentId);
// -- Run through the root one more time. If any child got added before it's parent, fix it.
foreach ( $hierarchy as $id => &$item ) {
$parentId = $item[$parentIdField];
if ( isset($itemReferences[$parentId] ) ) { // -- parent DOES exist
$itemReferences[$parentId][$childrenField][$id] = $item; // -- assign it to the parent's list of children
unset($hierarchy[$id]); // -- remove it from the root of the hierarchy
}
}
unset($itemReferences, $id, $item, $parentId);
return $hierarchy;
}
function enqueue()
{
wp_enqueue_style(
'redux-field-cat-sortable-css',
plugins_url('sortCss.css',__FILE__),
time(),
true
);
wp_enqueue_style(
'redux-field-nav-build-css',
plugins_url('nav_menu_builder.css',__FILE__),
time(),
true
);
wp_enqueue_script(
'jquery-nested-cat-sortable-js',
plugins_url('jquery.mjs.nestedSortable.js',__FILE__),
array('jquery','jquery-ui-core', 'jquery-ui-accordion'),
time(),
true
);
wp_enqueue_style(
'select2-css',
'//cdn.jsdelivr.net/select2/3.5.2/select2.css',
array(),
'3.5.2',//$this->timestamp,
'all'
);
Redux_CDN::enqueue_script(
'select2-js',
'//cdn.jsdelivr.net/select2/3.5.2/select2.min.js',
array( 'jquery', 'redux-select2-sortable-js' ),
'3.5.2',
true
);
wp_enqueue_script(
'jquery-nav-builder-js',
plugins_url('nav_menu_builder.js',__FILE__),
array('jquery'),
time(),
true
);
wp_enqueue_style(
'redux-field-media-css',
ReduxFramework::$_url . 'inc/fields/media/field_media.css',
time(),
true
);
wp_enqueue_style(
'redux-field-slideshow-css',
plugins_url('../slideshow-field/field_slides.css',__FILE__),
time(),
true
);
wp_enqueue_style(
'redux-field-page-builder-css',
plugins_url('../page-builder/page-builder.css',__FILE__),
time(),
true
);
}
}