Categories
Uncategorized

Recommended WordPress Plugin

Instagram Feed :
https://wordpress.org/plugins/wd-instagram-feed/
https://wordpress.org/plugins/instagram-feed/

Woocommerce Discount Rule :
https://www.flycart.org/products/wordpress/woocommerce-discount-rules

Woocommerce Filter Product :
https://wordpress.org/plugins/woocommerce-products-filter/

Woocommerce Custom Advanced Report :
https://aspengrovestudios.com/product/product-sales-report-pro-for-woocommerce/

Woocommerce Print Order Detail :
https://tokopress.id/plug-and-ship/

Categories
Uncategorized

Dynamic Value Selection – ContactForm7

Dynamic Select List in Contact Form 7

function dynamic_select_field_values ( $scanned_tag, $replace )
{

if ( $scanned_tag[‘name’] != ‘products’ )
return $scanned_tag;

$rows = get_posts(
array (
‘post_type’ => ‘products’,
‘numberposts’ => -1,
‘orderby’ => ‘title’,
‘order’ => ‘ASC’
)
);

if ( ! $rows )
return $scanned_tag;

foreach ( $rows as $row ) {
$scanned_tag[‘raw_values’][] = $row->post_title . ‘|’ . $row->post_title;
}

$pipes = new WPCF7_Pipes($scanned_tag[‘raw_values’]);

$scanned_tag[‘values’] = $pipes->collect_befores();
$scanned_tag[‘labels’] = $pipes->collect_afters();
$scanned_tag[‘pipes’] = $pipes;

return $scanned_tag;
}

add_filter( ‘wpcf7_form_tag’, ‘dynamic_select_field_values’, 10, 2);

Categories
Uncategorized

WordPress Menu Tree

class Menu_tree{

public $menu_list;
public $menu_items;

function __construct() {

$menu = wp_get_nav_menu_object( ‘main-menu’ );
$this->menu_items = wp_get_nav_menu_items($menu->term_id);
$this->menu_list = array();
$this->getMenu();
}

function getMenu(){

foreach( $this->menu_items as $key => $current ) {

$current->children = array();

if($current->menu_item_parent == 0) // first parent
{
$this->menu_list[ $current->ID ] = $current;
}
else
{
if(isset($this->menu_list[ $current->menu_item_parent ])) // if child of first parent
{
$this->menu_list[ $current->menu_item_parent ]->children[ $current->ID ] = $current;
}
else
{
$this->current = $current;
$this->checkChildren(); // Setting up CHILDREN
}
}

}

return $this->menu_list;
}

function checkChildren($data = array()){

$last_arr = end($this->menu_list);

if(empty($data)) // FIRST CHILDREN LOOP
{
foreach( $last_arr->children as $key => $current ) {

if( $current->ID == $this->current->menu_item_parent )
{
$current->children[ $this->current->ID ] = $this->current;
break;
}

if(!empty($current->children))
{
$this->checkChildren($current->children);
}
}
}
else // RELOOP TO Children
{
foreach( $data as $key => $current ) {
if( $current->ID == $this->current->menu_item_parent )
{
$current->children[ $this->current->ID ] = $this->current;
break;
}

if(!empty($current->children))
{
$this->checkChildren($current->children);
}
}
}
}
}