diff --git a/includes/wpbm-admin-page.php b/includes/wpbm-admin-page.php new file mode 100644 index 0000000..75defae --- /dev/null +++ b/includes/wpbm-admin-page.php @@ -0,0 +1,24 @@ + +
+

+

+ +
+ basename($og_image_url), + 'tmp_name' => $tmp + ); + + // Check for download errors + if (is_wp_error($tmp)) { + @unlink($file_array['tmp_name']); + return $tmp; + } + + // Handle the media upload + $id = media_handle_sideload($file_array, $post_id); + + // Check for handle sideload errors. + if (is_wp_error($id)) { + @unlink($file_array['tmp_name']); + return $id; + } + + // Set the featured image for the post + set_post_thumbnail($post_id, $id); +} + +function wpbm_handle_bookmarklet() { + if (!is_user_logged_in()) { + wp_redirect(wp_login_url(get_permalink())); + exit; + } + + $post_id = wp_insert_post(); + + // Set the featured image for the new post + wpbm_set_featured_image($post_id, $og_image); + + // Redirect to the new post page + wp_redirect(admin_url('post.php?post=' . $post_id . '&action=edit')); + exit; +} + +add_action('wp_ajax_wpbm_handle_bookmarklet', 'wpbm_handle_bookmarklet'); +add_action('wp_ajax_nopriv_wpbm_handle_bookmarklet', 'wpbm_handle_bookmarklet'); \ No newline at end of file diff --git a/includes/wpbm-post.php b/includes/wpbm-post.php new file mode 100644 index 0000000..3e0dcb9 --- /dev/null +++ b/includes/wpbm-post.php @@ -0,0 +1,24 @@ +'; + $content .= '

' . $description . '

'; + $content .= '

Read more

'; + } + return $content; +} +add_filter('default_content', 'wpbm_modify_post_content'); \ No newline at end of file diff --git a/wp-bookmark.php b/wp-bookmark.php new file mode 100644 index 0000000..32c59e4 --- /dev/null +++ b/wp-bookmark.php @@ -0,0 +1,14 @@ +