[Resolved] how to hook *.php file?

Home Forums Support how to hook *.php file?

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #902523
    d

    theme: 2.2.2
    GP Premium: 1.8.2

    I want to insert keywords,there is a php file that help me insert keywords from tag.
    but when I insert the php file,the hook system got wrong,How to slove this?Thanks.

    hook code:
    <?php include(‘seo.php’); ?>
    <?php
    if(is_single()){
    echo ‘<script type=”application/ld+json”>{
    …….et

    caution:
    Warning: include(): open_basedir restriction in effect. File(/www/server/php/72/lib/php/seo.php) is not within the allowed path(s): (/www/wwwroot/*/:/tmp/:/proc/) in /www/wwwroot/*/1557918395777/wp-content/themes/generatepress/header.php on line 19

    Warning: include(/www/server/php/72/lib/php/seo.php): failed to open stream: Operation not permitted in /www/wwwroot/*/1557918395777/wp-content/themes/generatepress/header.php on line 19

    Warning: include(): Failed opening ‘seo.php’ for inclusion (include_path=’.:/www/server/php/72/lib/php’) in /www/wwwroot/*/1557918395777/wp-content/themes/generatepress/header.php on line 19

    #902707
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Where exactly did you add your include? Have you tried with the full path to seo.php?

    #903275
    d

    this is seo.php file
    https://prntscr.com/nq4hj6
    this is hook setting
    https://prntscr.com/nq4hj5
    this is the caution
    https://prntscr.com/nq4hj7

    I just want to insert keywords meta from tag.if there is other way/other plugin can do,I could change the way.

    #903320
    d

    I use the mellow theme demo,where is the code to modify the space?(see image)
    this is the problem:
    https://prntscr.com/nq5esm
    this is my wordpress editor
    https://prntscr.com/nq5esk

    in normal,when didn’t use the section module,that’s no problem,
    it will be like this:
    https://prntscr.com/nq5fnd
    Thanks!Tom

    #903651
    Tom
    Lead Developer
    Lead Developer

    It’s possible that includes won’t work inside hooks at all.

    You may need to use a manual hook.

    For example:

    add_action( 'generate_before_content', function() {
        // Your include here.
    } );
    #904015
    d

    Thanks.Tom
    now,I use mellow demo as a company website.my question are:
    1. how to shut off the page default style(see the picture)?because the default theme-page-style is so narrow.
    https://prntscr.com/nqf1i2
    2. in gutenberg,the gallery can’t show at the frontend?(see the picture)
    https://prntscr.com/nqf1i1

    #904532
    Tom
    Lead Developer
    Lead Developer

    1. In Customize > Additional CSS, find and remove this CSS:

    .no-sidebar:not(.generate-columns-activated) .inside-article > *, .no-sidebar #comments {
        max-width: 700px;
        margin-left: auto;
        margin-right: auto;
    }

    2. I’m not too sure what you mean here. Can you explain a bit more?

    #908555
    d

    Thanks!Tom
    1st.thanks the additional CSS code,but if I want to change the entire page content to normal page(with hero,but no frame,see the picture),How?
    https://prntscr.com/nsb2ji

    3rd. I add the code(to disable comment’s website) in the functuion.php in child theme,but can’t work?
    the code:

    function alter_comment_form_fields($fields){
        //$fields['author'] = ''; //removes name field
        //$fields['email'] = '';  //removes email field
        $fields['url'] = '';  //removes website field
        return $fields;
    }
    add_filter('comment_form_default_fields','alter_comment_form_fields');
    add_filter('xmlrpc_enabled', '__return_false');

    the result
    https://prntscr.com/nsb2je

    4th, I read about the optimize in the generatepress(https://generatepress.com/fastest-wordpress-theme/) and the forum(somebody writed),
    I am confused about the “also aggregate inline CSS?”in CSS option.
    generatepress optimize tip said:It’s better to checked.
    somebody in the forum said:It’s better to unchecked(for website speed,for example:google PageSpeed Insights)
    now my option is unchecked.
    so it’s really to checked it for better speed and seo?can you give me some advisement.
    or it’s better to unchecked for better speed,because the inline css load at the sometime with HTML.

    5th.I am looking a lightweight post slider to show at the widget,I tried many plugin(smart slider is too big,Shortcodes Ultimate can’t work with the theme.et…),but I can’t find a perfected one, can you recommented a lightweight post slider?

    #909225
    Tom
    Lead Developer
    Lead Developer

    1. You could try the Page Builder Container option: https://docs.generatepress.com/article/page-builder-container/

    3. Try this:

    add_filter('comment_form_default_fields', function($fields) {
        unset( $fields['url'] );
        
        return $fields;
    }, 20 );

    4. That option should just grab our CSS in the <head> section and cache it in their CSS file. We have it checked here on our website. You can always test your site speed with and without.

    5. Maybe something like this?: https://wordpress.org/plugins/soliloquy-lite/

    #911256
    d

    Thanks!Tom
    I want to solve these :

    6. recommented lightbox plugin?
    the generatepress demo with lightbox,the plugin is WP Featherlight.but the plugin work only (In order for WordPress images and galleries to be lightboxed, you need to select the “Media File” option when choosing where the thumbnails should link.),so my Original article image isn’t select the “media file”,it’s a hard work to redo.
    but the Meow Lightbox plugin load more JS.
    so can you recomment a lightweight lightbox plugin or a method to solve it?

    7.thank to help me disable the comment website url with the function.php code. in fact,the code I paste is from my older theme, the code work with older theme,don’t work at generatepress theme.

    so I paste more optimize code(clean extra head) from older theme’s function.php.
    please to check it,is it right? or give me some method to optimize the extra head.Thanks.

    //about clean extra head
    //add_filter( ’emoji_svg_url’, ‘__return_false’ );

    remove_action(‘wp_head’, ‘feed_links’, 2 );
    remove_action(‘wp_head’, ‘feed_links_extra’, 3 );
    remove_action(‘wp_head’,’rsd_link’);
    remove_action(‘wp_head’,’wlwmanifest_link’);
    remove_action(‘wp_head’,’wp_generator’);
    remove_action(‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10, 0 );//rel=pre
    remove_action(‘wp_head’, ‘wp_shortlink_wp_head’, 10, 0 );//rel=shortlink

    //disable Embed
    remove_action(‘rest_api_init’, ‘wp_oembed_register_route’);
    remove_filter(‘rest_pre_serve_request’, ‘_oembed_rest_pre_serve_request’, 10, 4);

    remove_filter(‘oembed_dataparse’, ‘wp_filter_oembed_result’, 10 );
    remove_filter(‘oembed_response_data’, ‘get_oembed_response_data_rich’, 10, 4);

    remove_action(‘wp_head’, ‘wp_oembed_add_discovery_links’);
    remove_action(‘wp_head’, ‘wp_oembed_add_host_js’);

    //disable wp-json
    remove_action( ‘wp_head’, ‘rest_output_link_wp_head’, 10 );
    remove_action( ‘wp_head’, ‘wp_oembed_add_discovery_links’, 10 );

    #911362
    Tom
    Lead Developer
    Lead Developer

    6. I’ve only ever played with Featherlight, unfortunately. It is its own standalone library, so you should be able to tweak it to work however you like: https://noelboss.github.io/featherlight/

    7. That code looks good to me 🙂

    #916758
    d

    Thanks!Tom
    8.how to change the site-name in the navi (independent)?so I don’t need to load the logo image.
    I checked “Use Navigation as Header” and disable the hero navi color.
    https://prnt.sc/nw64cj

    9.the footer custom font style can’t work?
    https://prnt.sc/nw6bb7

    #917134
    Tom
    Lead Developer
    Lead Developer

    8. The title in your navigation uses the title in “Customize > Site Identity”.

    9. Not too sure what you mean?

    #917377
    d

    sorry for the ambiguity
    8. how to change the site-name-color in the navi? I set it,but it didn’t change the color.
    I checked “Use Navigation as Header” and disable the hero navi color.
    https://prnt.sc/nw64cj
    9. when I set font>footer>font size/ Font Weight,it didn’t working/changing.
    https://prnt.sc/nw6bb7

    #917775
    Tom
    Lead Developer
    Lead Developer

    8. You should be able to change it in Customize > Colors > Header.

    9. The footer options are for the copyright bar. We’ll likely need to use CSS to target the footer widgets. What are you wanting to change?

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