Main function that extracts content from the configured URL and publishes posts.
Returns: void
Usage:
ce_extract_content();Hooks:
ce_before_extraction- Fires before extraction startsce_after_extraction- Fires after extraction completes
Parses the response body and publishes posts to WordPress.
Parameters:
$body(string) - The HTML/XML/JSON response body to parse
Returns: array - Array of created post IDs
Usage:
$response = wp_remote_get( $url );
$body = wp_remote_retrieve_body( $response );
$post_ids = ce_parse_and_publish_content( $body );Downloads and sets a featured image for a post.
Parameters:
$post_id(int) - WordPress post ID$image_url(string) - URL of the image to download
Returns: bool - true on success, false on failure
Usage:
$success = ce_set_featured_image( 123, 'https://example.com/image.jpg' );Logs an error message if WP_DEBUG is enabled.
Parameters:
$message(string) - Error message to log
Returns: void
Usage:
ce_log_error( 'Failed to fetch content from ' . $url );Fires before content extraction begins.
add_action( 'ce_before_extraction', function() {
// Your code here
});Fires after content extraction completes.
add_action( 'ce_after_extraction', function( $post_ids ) {
// $post_ids is array of created post IDs
});Filter the source URL before fetching.
add_filter( 'ce_source_url', function( $url ) {
// Modify URL
return $url;
});Filter post data before publishing.
add_filter( 'ce_post_data', function( $post_data, $source_data ) {
// Modify post data
return $post_data;
}, 10, 2 );Stores plugin settings.
Structure:
array(
'ce_url' => 'https://example.com/api/posts'
)Get:
$options = get_option( 'ce_settings' );
$url = $options['ce_url'] ?? '';Update:
update_option( 'ce_settings', array(
'ce_url' => 'https://new-url.com'
) );Stores the current page number for pagination.
Get:
$page = get_option( 'ce_current_page', 1 );Update:
update_option( 'ce_current_page', 2 );