Tagged: ,

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #362748

    Hey,

    since the last update of the theme, some functionality of my child theme stopped working,
    and i need your help, cause i cant figure out what have changed in the enfold theme that caused that,
    my functionality was added to a child theme in order to support ajax call to get a page that was edited via the avia layout builder.

    function partialRefresh($page_name,$post_type,$user_country_code) {
    $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);
    $content = apply_filters(‘avia_builder_precompile’, get_post_meta($the_id, ‘_aviaLayoutBuilderCleanData’, true));
    $content = apply_filters(‘the_content’, do_shortcode($content));
    }

    return $content;
    }

    before the update i was getting html,
    now i get WordPress shortcode of the blog.

    [av_heading tag=’h3′ padding=’10’ heading=’Select a country you want to open a bank account in’ color=’meta-heading’ style=’blockquote modern-quote modern-centered’ custom_font=” size=” subheading_active=” subheading_size=’15’ custom_class=”] dfsfdsfds
    [/av_heading] [av_blog blog_type=’taxonomy’ post_type=’country’ categories=’141′ link=’country-category,1′ blog_style=’blog-grid’ columns=’5′ contents=’title’ content_length=’excerpt’ preview_mode=’auto’ image_size=’no scaling’ items=’-1′ offset=’0′ paginate=’no’]
    please what am i doing wrong? it seems that at this point, (child theme function file) the shortcodes of the Avia builder are not registered yet.

    how can i get this to work???

    #363638

    Hi bankaccounts!

    Hmm, not sure what could be going on there. It doesn’t look like it’s using AJAX, your using it as a shortcode correct? Can you give us the full code so we can test it out?

    Best regards,
    Elliott

    #363962

    you need access to my web site ftp?

    #364321

    Hi!

    Go ahead and paste the full code your using here and we’ll take a look.

    Best regards,
    Elliott

    #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);
    });

    #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;
    }
    }

    #364873

    Hey!

    It looks pretty specific. Not sure if we will be able to help you with this or not but send us a WordPress login and we’ll take a look.

    It would probably be best to contact the developer who created this for you though.

    Cheers!
    Elliott

    #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?

    #365398

    Hey!

    First off I would try switching all of the “$” in your javascript code to “jQuery”. And then send us a WordPress login so we can take a look.

    Cheers!
    Elliott

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.