aaroneaton / better-yourls

Source code for the Better YOURLS WordPress plugin
21 stars 6 forks source link

Integrity checking and TinyMCE integration #20

Open generationtech opened 6 years ago

generationtech commented 6 years ago

This PR adds shortlink integrity checking on the YOURLS server for a shortlink on the WP side. Also adds TinyMCE button to create/insert a YOURLS shortlink.

The PR has minify disabled to be re-enabled in future changes on primary repo by owner

Details:

1. When a WP content is created/edited and has an existing shortlink in the metadata, the plugin checks the YOURLS server to make certain the shortlink actually exists over there and has not been orphaned (admin deleted on YOURLS server side).

If the shortlink does not exist on YOURLS server, the plugin will search the YOURLS server for an existing shortcode for that WP long URL

If no existing long URL found on the YOURLS server, a new YOURLS shortlink is created there with the same existing keyword in WP content

When searching for an existing long URL on the YOURLS server, the plugin can either search for the most recent or oldest existing long URL the corresponds with the WP content and pull the shortlink from the YOURLS server

2. When a WP content is created/edited and has NO existing shortcode in the metadata, the plugin will search the YOURLS server for an existing shortcode for that WP long URL.

When searching for an existing long URL on the YOURLS server, the plugin can either search for the most recent or oldest existing long URL the corresponds with the WP content and pull the shortlink from the YOURLS server

3. Added a button in tinymce to open a custom dialog for inserting a general purpose long URL and have it created on the YOURLS server and shortlink inserted in the WP content.

Option for link text

Option for "open in new window"

If the "Text" field is not used on the insert dialog, the long URL website title is pulled from YOURLS server when shortlink is created

Also same functionality to search for existing shortlink on YOURLS sever for the used-inserted general purpose long URL

If the user-inserted general purpose long URL is actually an existing shortlink from the YOURLS server, the plugin will not "re shorten it" to incorrectly make a shortlink-to-a-shortlink

4. Added to the Better YOURLS admin settings page options to control the shortlink integrity functions.

5. On the YOURLS server side, created an API plugin there to support the expanded API DB interface to support the needed functions on YOURLS server side.

ChrisWiegman commented 6 years ago

My apologies as I'm just seeing this now (thank you, GitHub, for filtering all my emails to spam). I will look into this shortly. Thank you for the submission.

generationtech commented 5 years ago

Looks like this didn't get merge because it failed some check. Guess I'll look into why