Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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

    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

    Thread Starter enpitsu

    (@enpitsu)

    Unfortunately my Chrome don’t have any extensions, i event test this on Microsoft Edge and still see the bug. If i downgrate from ver 6.2 back to 6.1.1, the bug will disappear, re-appear when upgrate to 6.2.

    Thread Starter enpitsu

    (@enpitsu)

    I make a quick demo video, hope this will make you easier to see.

    https://drive.google.com/file/d/15NomozIKXXJy4suw5OMi42R-64dvBFlf/view?usp=sharing

    Thread Starter enpitsu

    (@enpitsu)

    That odd, i make sure that no plugin is in use, i even reinstall wp all over again. I only see this with Block Editor, the Classic Editor work perfectly fine, also i using chrome.

    Thread Starter enpitsu

    (@enpitsu)

    Thanks for your reply.

    Just add this code to theme file functions.php:

    function add_custom_meta_box() {
    add_meta_box(
    'custom_meta_box',
    'Custom WYSIWYG Field',
    'custom_meta_box_callback',
    'post',
    'normal',
    'high'
    );
    }
    add_action('add_meta_boxes', 'add_custom_meta_box'); function custom_meta_box_callback($post) {
    $content = get_post_meta($post->ID, 'custom_wysiwyg_field', true);
    $editor_id = 'custom_wysiwyg_field';
    $settings = array(
    'textarea_rows' => 10,
    'media_buttons' => true,
    'teeny' => false,
    'textarea_name' => 'custom_wysiwyg_field'
    );
    wp_editor($content, $editor_id, $settings);
    } function save_custom_meta_box_data($post_id) {
    if (array_key_exists('custom_wysiwyg_field', $_POST)) {
    update_post_meta(
    $post_id,
    'custom_wysiwyg_field',
    $_POST['custom_wysiwyg_field']
    );
    }
    }
    add_action('save_post', 'save_custom_meta_box_data');
Viewing 6 replies - 1 through 6 (of 6 total)