Need some Help With "Snippet to Remove GeoDirectory Scripts"

This topic contains 7 replies, has 3 voices, and was last updated by  Stiofan O’Connor 6 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #414740

    Jason Gillespie
    Expired Member
    Post count: 78

    Need some Help With “Snippet to Remove GeoDirectory Scripts”

    Here’s what I’m using:
    https://wpgeodirectory.com/docs/common-code-snippets/

    add_action( ‘wp’, ‘wpdocs_dequeue_script’, 100 );
    function wpdocs_dequeue_script() {
    if (!geodir_is_geodir_page()){
    remove_action(‘wp_enqueue_scripts’, ‘geodir_templates_scripts’);
    remove_action(‘wp_enqueue_scripts’, ‘geodir_templates_styles’, 8);
    }
    }

    On line 3 I need add to where I can add blog pages and pages by page id to this.

    example:

    post-id-284 – has Geodirectory items in sidebar. I would like to be able to add certain pages and post to this function also.

    Hope this makes since…

    #414746

    Dirk
    Full Member
    Post count: 390

    Hi Jason,

    in general you can add
    global $post;
    to your function. The ID is $post->ID;
    You can also use the wordpress function get_the_ID();

    For testing print_r ( $post ); to see what is all in the $post variable.

    Now you can modify your if statement.

    But as the link to the snippet is telling, with this example you are just preventing wordpress to enqueue the scripts for GD Core. There might be GD addons with additional scripts and CSS code.

    As an alternative you can dequeue the scripts and CSS code with wp_dequeue_script().

    BTW: I think style sheets should be registered via wp_enqueue_style().

    Best,
    Dirk

    #414764

    Jason Gillespie
    Expired Member
    Post count: 78

    That’s what I’m working on is optimizing the plugin and all the add-ons I’m using.

    Wanting to only use scripts and CSS and where its needed.

    I’m not a php expert. I’ve used dequeue before with Genesis…

    Here’s what I’m wanting to optimize:

    Geodirectory
    Geodirectory advance search filters
    Geodirectory claim manager
    Geodirectory custom post types
    Geodirectory location manager
    Geodirectory payment manager
    Geodirectory re-captcha
    Invoicing
    Not installed yet Stripe payment gateway

    #414765

    Jason Gillespie
    Expired Member
    Post count: 78
    This reply has been marked as private.
    #414785

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    u could do something like this (only part of ur script):

    
    
    function wpdocs_dequeue_script() {
    global $post;
    $inc_page_ids = array(123,321,111,222,333);
    if (!geodir_is_geodir_page() && !in_array($post->ID,$inc_page_ids) ){

    Stiofan

    #414841

    Jason Gillespie
    Expired Member
    Post count: 78

    That’s it, that’s what I was looking for. Thank you very much Stiofan!

    #414918

    Jason Gillespie
    Expired Member
    Post count: 78

    Worked PERFECTLY Stiofan.

    This 1 simple change reduced non Geodirectory pages to 800MS load time boss man! That’s where it’s at right there.

    Before the change, non Geodirectory pages loaded in 1800MS.

    That saves 1 full second on load time.

    I don’t even have rocket cache setup yet but I have tested on another test site and works GREAT!

    Thanks again!

    #414956

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Thanks for the feedback!

    Stiofan

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket