Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Enfold Ajax Partial Refresh #364875

    i have created it , it is not specific at all.
    it does what templatebuilder.php does
    but now after the update it is stopped working,
    do you give support from one of your developers?

    in reply to: Enfold Ajax Partial Refresh #364365

    /* —————- Handle ajax calls ———————- */
    if (!function_exists(‘handle_ajax_function’)) {
    function handle_ajax_function()
    {
    ob_clean();

    switch ($_POST[‘fn’]) {
    case ‘partialRefresh’:
    global $wp;
    $post_type=$_POST[‘post_type’];
    $user_country_code=$_POST[‘user_country_code’];
    $page_name=$_POST[‘page_name’];
    $output = partialRefresh($page_name,$post_type,$user_country_code);
    echo $output;
    die();
    break;
    default:
    $output = ‘No function specified, check your jQuery.ajax() call’;
    break;
    }
    }
    add_action(‘wp_ajax_nopriv_do_ajax’, ‘handle_ajax_function’);
    add_action(‘wp_ajax_do_ajax’, ‘handle_ajax_function’);
    }

    if (!function_exists(‘partialRefresh’)) {
    function partialRefresh($page_name,$post_type,$user_country_code) {
    global $wp;
    ob_start();
    $query = array( ‘post_type’ => $post_type, ‘name’ => $page_name,’post_status’ => ‘publish’ );
    $query = new WP_Query($query);
    if ( !$query->have_posts() ) {die(“page not found !”);}
    $query->the_post();
    $post = $query->post;
    $output=””;
    $the_id = $post->ID;
    $wp->the_id = $the_id;

    if(‘active’ == get_post_meta($the_id, ‘_aviaLayoutBuilder_active’, true)){
    global $avia_config;
    ShortcodeHelper::$tree = get_post_meta($the_id, ‘_avia_builder_shortcode_tree’, true);
    $avia_config[‘conditionals’][‘is_builder_template’] = false;
    get_template_part(‘template-builder’);
    }

    $output = ob_get_contents();
    $dom = new DomDocument();
    @$dom->loadHTML($output);
    $xpath = new DomXPath($dom);
    $newDom=new DomDocument();
    $container = $xpath->query(‘//main[@role=”main”]’);
    $node = $newDom->importNode( $container->item(0), true );
    $newDom->appendChild($node);
    $output=$newDom->saveHTML();
    ob_end_clean();
    wp_reset_postdata();
    return $output;
    }
    }

    in reply to: Enfold Ajax Partial Refresh #364363

    this is the java script that pots for page request:

    $=jQuery;
    var page_name = countries.page_name;
    homeUrl = countries.homeUrl;

    function get_page(homeUrl,page_name,post_type,user_country_code,container,success){
    $.ajax({
    type: “POST”,
    url: homeUrl + ‘/wp-admin/admin-ajax.php’,
    data: {
    ‘action’: ‘do_ajax’,
    ‘fn’: ‘partialRefresh’,
    ‘page_name’: page_name,
    ‘post_type’: post_type,
    ‘user_country_code’: user_country_code,
    },
    success: function (data) {
    container.html(data);
    success();
    },
    error: function (request, status, error) {
    //alert(request.responseText);
    },
    async: false
    });
    }

    var success = function(){
    $(“*”).unbind(); // unbind all elements from js events
    jQuery.getScript(“../wp-content/themes/enfold/js/avia.js”, function(data, textStatus, jqxhr){});//get bootstrap js reloaded
    }

    $(document).on( “saveUserCountryCode_done”, function(event,selected_country_code) {
    get_page(homeUrl,page_name,’page’,selected_country_code,$(“main[role=’main’]”).parent(),success,5000,1000);
    });

    in reply to: Enfold Ajax Partial Refresh #363962

    you need access to my web site ftp?

Viewing 4 posts - 1 through 4 (of 4 total)