Skip to content

Commit

Permalink
Made changes per WordPress Plugin reviewer's guidelines. Plugin now a…
Browse files Browse the repository at this point in the history
…pproved and moved to version 1.0.
  • Loading branch information
zerosonesfun committed Jan 22, 2024
1 parent 4629bfe commit a318bc8
Show file tree
Hide file tree
Showing 9 changed files with 474 additions and 421 deletions.
339 changes: 0 additions & 339 deletions LICENSE

This file was deleted.

400 changes: 400 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# wp-bookmark
A WordPress plugin. Click a bookmark on any web page to send that page's title, description, and open graph image to your new post page. It's like the old "Press This." But, it works with the new editor.
Click a bookmark on any web page to send that page's title, description, and open graph image to your new post page. It's like the old "Press This." But, it works with the new editor.

## Installation & How to use
- Download the zip file
Expand Down
Binary file added includes/.DS_Store
Binary file not shown.
33 changes: 20 additions & 13 deletions includes/wpbm-admin-page.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
<?php
if (!defined('ABSPATH')) exit; // Exit if accessed directly

// Function to create the admin page
function wpbm_bookmarklet_page() {
$plugin_url = plugins_url('', __FILE__);
$site_url = site_url();
function bmwpskywolf_bookmarklet_page() {
$plugin_url = esc_url_raw(plugins_url('', __FILE__));
$site_url = esc_url(home_url());

$description = isset($_GET['content']) ? wp_kses_post(sanitize_text_field($_GET['content'])) : '';

$og_image = '';
if (isset($_GET['wpbm_og_image'])) {
$og_image = esc_url(sanitize_url($_GET['wpbm_og_image']));
}

$bookmarklet_code = "
javascript:(function(){var t=encodeURIComponent(document.title),d=document.querySelector('meta[name=\"description\"]'),u=encodeURIComponent(window.location.href),i=document.querySelector('meta[property=\"og:image\"]');d=d?encodeURIComponent(d.content):'No description available';i=i?encodeURIComponent(i.content):'No image available';var r=\"$site_url/wp-admin/post-new.php?post_type=post\";r+=\"&title=\"+t+\"&content=\"+d+\"&wpbm_url=\"+u+\"&wpbm_og_image=\"+i;window.location.href=r;})();
";
$bookmarklet_code = "javascript:(function(){var t=encodeURIComponent(document.title),d=document.querySelector('meta[name=\"description\"]'),u=encodeURIComponent(window.location.href),i=document.querySelector('meta[property=\"og:image\"]');d=d?encodeURIComponent(d.getAttribute('content')):'No description available';i=i?encodeURIComponent(i.getAttribute('content')):'No image available';var r='" . esc_url($site_url) . "/wp-admin/post-new.php?post_type=post'+'&title='+t+'&content='+d+'&wpbm_url='+u+'&wpbm_og_image='+i;window.location.href=r;})();";

?>
<div class="wrap">
<h1><?php echo esc_html__('Bookmarklet', 'wpbm'); ?></h1>
<p><?php echo esc_html__('Copy the code below and paste it as a new browser bookmark\'s URL.', 'wpbm'); ?></p>
<textarea rows="5" cols="50" id="bookmarklet-code"><?php echo esc_textarea($bookmarklet_code); ?></textarea>
<h1><?php echo esc_html__('Bookmarklet', 'bmwpskywolf'); ?></h1>
<p><?php echo esc_html__('Copy the code below and paste it as a new browser bookmark\'s URL.', 'bmwpskywolf'); ?></p>
<textarea rows="5" cols="50" id="bookmarklet-code"><?php echo esc_textarea($bookmarklet_code); ?></textarea>
</div>
<?php
}

// Add the admin menu page
function wpbm_add_admin_menu() {
add_management_page('Bookmarklet', 'Bookmarklet', 'manage_options', 'wpbm-bookmarklet', 'wpbm_bookmarklet_page');
// Add the admin menu page within tools
function bmwpskywolf_add_admin_menu() {
add_management_page('Bookmarklet', 'Bookmarklet', 'manage_options', 'wpbm-bookmarklet', 'bmwpskywolf_bookmarklet_page');
}
add_action('admin_menu', 'wpbm_add_admin_menu');
add_action('admin_menu', 'bmwpskywolf_add_admin_menu');
53 changes: 0 additions & 53 deletions includes/wpbm-handle-bookmarklet.php

This file was deleted.

22 changes: 13 additions & 9 deletions includes/wpbm-post.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?php
function wpbm_modify_post_title($title) {
if (!defined('ABSPATH')) exit; // Exit if accessed directly

function bmwpskywolf_modify_post_title($title) {
if (isset($_GET['title'])) {
$title = sanitize_text_field($_GET['title']);
$title = stripslashes($title); // Remove slashes
}

return $title;
return esc_html($title);
}
add_filter('default_title', 'wpbm_modify_post_title');
add_filter('default_title', 'bmwpskywolf_modify_post_title');

function wpbm_modify_post_content($content) {
function bmwpskywolf_modify_post_content($content) {
if (isset($_GET['content']) && isset($_GET['wpbm_url']) && isset($_GET['wpbm_og_image'])) {
$description = sanitize_text_field($_GET['content']);
$url = filter_var($_GET['wpbm_url'], FILTER_SANITIZE_URL);
$og_image = filter_var($_GET['wpbm_og_image'], FILTER_SANITIZE_URL);
$description = wp_kses_post(sanitize_text_field($_GET['content']));
$description = stripslashes($description); // Remove slashes

$url = esc_url(sanitize_url($_GET['wpbm_url']));
$og_image = esc_url(sanitize_url($_GET['wpbm_og_image']));

// Create the post content
$content = '<img src="' . $og_image . '" />';
Expand All @@ -21,4 +25,4 @@ function wpbm_modify_post_content($content) {
}
return $content;
}
add_filter('default_content', 'wpbm_modify_post_content');
add_filter('default_content', 'bmwpskywolf_modify_post_content');
34 changes: 34 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
=== bookmark wp ===
Contributors: wilcosky
Tags: bookmark, bookmarklet
Requires at least: 6.0
Tested up to: 6.4.2
Stable tag: 1.0
Requires PHP: 7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Bookmark/share webpages by clicking a special bookmark in your browser called a bookmarklet. It's like the old "Press This." But, it's minimal, and it works with the new editor. If you know, you know. Go to the Installation tab to learn how to set it up. Contribute at:
https://github.com/zerosonesfun/wp-bookmark


== Installation ==

1. Within the admin dashboard go to Plugins --> Add New
2. Search for "wp bookmark"
3. Choose activate, and then install
4. Go to Tools, then Bookmarklet, and copy the code
5. Paste the code into the URL field of a new browser bookmark that you create
6. On any webpage click on the new bookmark you made

Alternative install method: From the Add Plugins page choose Upload Plugin and upload this plugin's zip file.

== Frequently Asked Questions ==

= Are there any FAQs? =
No. This is the initial release.

== Changelog ==

= 1.0 =
* Initial release
12 changes: 6 additions & 6 deletions wp-bookmark.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
/*
Plugin Name: WP Bookmark
Description: A bookmarking plugin for WordPress.
Version: 0.1
Plugin Name: bookmark wp
Description: A bookmarking/reposting plugin for WordPress similar to the old Press This feature.
Version: 1.0
Author: Billy Wilcosky
Author URI: https://wilcosky.com
Author URI: https://wilcosky.com/skywolf
License: GPL-2.0+
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Include necessary files
include(plugin_dir_path(__FILE__) . 'includes/wpbm-admin-page.php');
include(plugin_dir_path(__FILE__) . 'includes/wpbm-post.php');
include(plugin_dir_path(__FILE__) . 'includes/wpbm-handle-bookmarklet.php');
include(plugin_dir_path(__FILE__) . 'includes/wpbm-post.php');

0 comments on commit a318bc8

Please sign in to comment.