• Resolved enpitsu

    (@enpitsu)


    I notice that since version 7.1, you guy “Refactoring content analysis code”, the hook seopress_content_analysis_content not working anymore. In your plugin, i still see add_filter(‘seopress_content_analysis_content’) but don’t see apply_filter(‘seopress_content_analysis_content’) anymore. My question is now that you guy don’t use this hook anymore then there are anyway that let me add my custom field to content analysis cause in your doc i still see this hook. Or a temporary solution is fine.

    Thank you

    https://www.seopress.org/support/hooks/filter-the-analyzed-content/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Benjamin Denis

    (@rainbowgeek)

    Hi,

    please update to 7.1.2. This should solve the issue.

    Thanks

    Thread Starter enpitsu

    (@enpitsu)

    I just try what you suggest and see the apply_filter() in DomAnalysist.php still missing one in ajax.php compare to older version. Futher more, i test the hook by using it and print out the content before and after the filter to see there are anything that change but nothing happen like my code not even running. Any suggest, i will gladly to try.

    Thank you

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    Hi,

    can you share your code used please?

    Thread Starter enpitsu

    (@enpitsu)

    Here my test code in theme function.php :

    // Add a custom text field to the theme options
    function add_custom_meta_box() {
        add_meta_box(
            'custom_meta_box',
            'Custom Text Field', // Change title to reflect the text field
            'custom_meta_box_callback_text', // Change callback function name
            'post',
            'normal',
            'high'
        );
    }
    add_action('add_meta_boxes', 'add_custom_meta_box');
    
    function custom_meta_box_callback_text($post) {
        $text_value = get_post_meta($post->ID, 'custom_text_field', true);
        ?>
    <label for="custom_text_field">Enter Text:</label><br>
    <input type="text" id="custom_text_field" name="custom_text_field" value="<?php echo esc_attr($text_value); ?>">
    <?php
    }
    
    function save_custom_meta_box_data($post_id) {
        if (array_key_exists('custom_text_field', $_POST)) {
            update_post_meta(
                $post_id,
                'custom_text_field',
                sanitize_text_field($_POST['custom_text_field']) // Sanitize text input
            );
        }
    }
    add_action('save_post', 'save_custom_meta_box_data');
    
    function sp_content_analysis_content($content, $id) { 
    	//$content = default WP editor 
    	//$id = current post ID 
    	//Example to add your custom field to content analysis
    	//Flexible content must be called like this: name_of_your_flexible_content_0_name_of_your_field
    	$cf = get_post_meta($id, 'custom_meta_box', true); 
    	$content = $content.$cf; 
    	return $content;
    }
    add_filter('seopress_content_analysis_content', 'sp_content_analysis_content', 10, 2);

    First, i try to create a text field then add https://youtube.com to it value, then i use your filter. What i expect here is in Content analysis tab Outbound Links will have https://youtube.com in it but nothing happen.

    Please let me know if you can recreate it, thank you

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    You meta key is:

    custom_text_field

    Not custom_meta_box here:

    $cf = get_post_meta($id, 'custom_meta_box', true);

    Is it better if you change this?

    Plugin Author Benjamin Denis

    (@rainbowgeek)

    We are now closing this topic due to inactivity. Thank you for your understanding.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘seopress_content_analysis_content hook is not useable’ is closed to new replies.