GithubHelp home page GithubHelp logo

markjaquith / page-links-to Goto Github PK

View Code? Open in Web Editor NEW
108.0 7.0 48.0 2.88 MB

#WordPressPlugin: Lets you make a WordPress page (or other content type) link to an external URL of your choosing, instead of its WordPress URL.

License: GNU General Public License v2.0

Shell 5.86% PHP 52.11% JavaScript 40.75% Sass 1.28%
wordpress wordpress-plugin

page-links-to's Introduction

Page Links To

Build Status

Contributors: markjaquith
Donate link: https://txfx.net/wordpress-plugins/donate
Tags: page, redirect, link, external link, repoint
Requires at least: 4.8
Tested up to: 5.8
Stable tag: 3.3.6

Lets you make a WordPress page (or port or other content type) link to a URL of your choosing (on your site, or on another site), instead of its normal WordPress URL.

Description

This plugin allows you to make a WordPress page (or post or custom post type) link to a URL of your choosing, instead of its WordPress URL. It also will redirect people who go to the old (or "normal") URL to the new one you've chosen.

Common uses:

  • Set up navigational links to non-WordPress sections of your site or to off-site resources.
  • Publish content on other blogs (or other services, like Medium) but have them show up in your WordPress posts stream. All you have to supply is a title and a URL. The post title will link to the content on the other site.
  • For store operators, you can link to products on other retailer's sites (maybe with an affiliate code) but have them show up like they're products in your store.
  • Create a "pretty URL" for something complicated. Say you have https://example.com/crazy-store-url.cgi?search=productId&sourceJunk=cruft ... just create a WordPress page called "My Store" and use Page Links To to point it to the ugly URL. Give people the new URL: https://example.com/my-store/ and it will redirect them!

Installation

  1. Upload the page-links-to folder to your /wp-content/plugins/ directory.

  2. Activate the "Page Links To" plugin.

Existing Content Usage:

  1. Edit a page (or post or custom post type).

  2. Below, find the Page Links To widget, select "A custom URL", and add a URL of your choosing.

  3. Optionally check the box to enable link opening in a new browser tab.

  4. Save the page (or post or custom post type).

  5. Done! Now that content will point to the URL that you chose. Also, if anyone had the old WordPress URL for that content, they will be redirected to the custom URL if they visit.

Creating New Page Links:

  1. Click Pages > Add New Page Link.

  2. Provide a title and a destination URL.

  3. Optionally provide a custom slug, which will be used in creating a local redirect URL.

  4. Click Publish.

Screenshots

  1. The Page Links To meta box in action
  2. The quick Add Page Link dialog.

Frequently Asked Questions

How do I make it so that a page doesn't link to anything? I'd like to use it as a dummy container.

Just use "#" as the link. That won't go anywhere.

Can this be used to repoint categories to an arbitrary URL?

Not currently. Please contact me if you're interested in that functionality.

My links are sending me to http://myblog.com/site-i-wanted-to-link-to.com ... why?

If you want to link to a full URL, you must include the http:// portion.

Can I link to relative URLs for URLs on the same domain?

Yes. Linking to /my-photos.php is a good idea, as it'll still work if you move your site to a different domain.

Contribute

You can contribute (or report bugs) on Github.

Changelog

3.3.5

  • Fix a bug that could cause new installs to constantly try to update the storage format.

3.3.4

  • Bug fixes

3.3.3

  • Add a SlotFill in the Block Editor, for extension.
  • Fix New Tab support in Internet Explorer.

3.3.2

  • Fix a small new tab JS error.

3.3.1

  • Fix WordPress 5.2 Block Editor (plugin will NOT be in its own panel if you're using WordPress 5.2).

3.3.0

  • Move Block Editor UI into its own panel.
  • Compatibility with Elementor.
  • Allow posts to load in the customizer (used by some front-end editing plugins).
  • Allow the "open in new tab" functionality to be completely disabled with a filter.
  • Make "open in new tab" more reliable.

3.2.2

  • Bug fixes
  • Better compat with custom post types in the Block Editor

3.2.1

  • Bug fixes

3.2.0

  • Block Editor improvements
  • Smaller build

3.1.2

  • Customizer bug fix

3.1.1

  • Block Editor bugfixes

3.1.0

  • Support for the Block Editor (Gutenberg)

3.0.1

  • Fixed a PHP warning caused by some themes

3.0.0

  • Quick page link adding UI
  • External link indicator
  • Short URL copying
  • Short URL display on edit screen

2.11.2

  • Newsletter

2.11.1

  • Restore PHP 5.3 compatibility, broken in 2.11.0

2.11.0

  • Code cleanup

2.10.4

  • New screenshot and assets

2.10.3

  • Fix readme.txt

2.10.2

  • Fix bug in Internet Explorer

2.10.1

  • Version bump

2.10.0

  • Switch to ES6 and Babel from CoffeeScript
  • Remove jQuery as front-end requirement
  • Bump supported version

2.9.10

  • Bump supported version

2.9.9

  • Back out jQuery protection code that causes issues on some sites

2.9.8

  • Added a Russian translation
  • Maintain a reference to WordPress' jQuery version
  • Modernize build tools

2.9.6

  • Fixed an issue with redirects that have @ in the URL
  • Fixed issues with setting and displaying custom URLs for attachments

2.9.5

  • Made relative URLs absolute in redirects
  • Fixed a potential PHP warning
  • Registered the metadata fields for better XML-RPC integration

2.9.4

  • Add Hungarian translation.

2.9.3

  • Only rely on an internal cache for wp_list_pages() processing, and time-limit the cache.
  • Work around some weird edge cases

2.9.2

  • Restore WordPress 3.4.x functionality.

2.9.1

  • Fix a redirection bug in 2.9

2.9

  • Respect "open in new tab" setting in more custom situations, like custom loops and widgets.
  • Add unit tests
  • Massive code refactoring
  • Added translations for: Spanish, Catalan, French.

2.8

  • Added translations for: Swedish, Hebrew.

2.7.1

  • Fix an array bug

2.7

  • Fix a PHP notice
  • Use JS to open links in an external window, even outside of nav menus
  • Completely revamped UI
  • Several translations

2.6

  • Proper linking for custom post types (insead of just a 301).
  • Fixed a bug that prevented links from opening in a new window.
  • Notifies people when they are editing content that uses this plugin.
  • Removed the option to set redirection type. Always 301, now.
  • Removed some PHP4 and WP 2.8 back compat stuff.

2.5

  • Allow all show_ui post types to use the meta box.
  • Introduce a filter so a plugin can remove a post type from the list.
  • Target filtering for WordPress nav menus.
  • Silence some PHP notices. Props Ross McKay, Bill Erickson.

2.4.1

  • Fixed typo that was preventing 302 redirects from working. props Ryan Murphy.
  • Fixed a random PHP notice

2.4

  • Rewrote using Singleton best practices
  • Fixed a regex bug that could break current menu highlighting. props skarab

2.3

  • Fixed a bug with current menu item highlighting

2.2

  • Cleanup
  • compatibility tweaks to interoperate with a few other plugins
  • prompt http:// and auto-add it if a URL starts with "www."

2.1

  • WordPress MU compatibility for when switch_to_blog() is used... it now uses $blog_id to keep their caches from stomping on each other

2.0

  • Allow one-character URLs so that things like "#" (dummy link) are possible

1.9

  • Fixed "open in new window" functionality

page-links-to's People

Contributors

cfoellmann avatar danielpunkass avatar defunctl avatar dependabot[bot] avatar ellipsis753 avatar fmarier avatar markjaquith avatar meszarosrob avatar natanaelsinisalo avatar peterdavehello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

page-links-to's Issues

Google Analytics Tracking

I setup a "page links to" that allows my site to basically be used as a "passthrough" for my visitors to access another websites. I tried using a Google Analytics tracking URL but it doesn't work. Is there a certain way that I can track these URLs?

new tab

when i press the link it doesnt open in a new tab

Remove inline code

Can you please convert this to a queue-able script? It messes up with caching plugins and jQuery when it's deferred.

3.0.0 upgrade causes error message

I just updated to the v.3.0.0 plugin this morning, using the built in "Upgrade" function from the Wordpress Plug-ins setting page.

Now my page presents this error in the top of every page.

Warning: Missing argument 3 for CWS_PageLinksTo::wp_list_pages() in /home/my_blogs_directory_name/public_html/blog/wp-content/plugins/page-links-to/classes/plugin.php on line 650

I am on WP 4.9.7 using a custom theme made in Artisteer.

Installed active plugins are:

  • Aksimet Anti-Spam 4.0.8
  • Blogroll Links 2.3
  • Duplicate Post 3.2.2
  • Easy Logo Slider 1.2.1
  • Exclude Pages from Navigation 1.9.2
  • Google Photos & Picasa Viewer 3.0.13
  • Jetpack 6.3.2
  • Page Links To 3.0.0
  • Responsive Lightbox & Gallery 2.0.5
  • Simple Calendar 3.1.18
  • TinyMCE Advanced 4.7.11
  • WPtouch Mobile Plugin 4.3.28

I'm browsing from Chrome but it looks like it does it in all browsers.

Any help fixing it, or a .zip of the prior version, would be appreciated. (Edit: I just found the 2.11.0 .zip in the past Commits list.)

Make pretty url creation more obvious

Idea: Add a Pages menu item "Add Page Link" that presents a super simple modal UI:

[ Title ]
[ URL ]
http://example.com/[Short URL slug]
[Save] [Publish]

When Activated, Search Breaks on Gazette Theme

This theme https://theme.wordpress.com/themes/gazette/, which is available to download and run on .org sites, has a Search button and a Responsive Menu Hamburger, that don't trigger when this plugin is active.
Sorry I don't have the chops to see what the issue is; thought I would report it here anyway just in case others are experience similar behaviour beyond compatibility with a random theme.

How can I do this with PHP?

How can I use your function to change a post id into a redirect link with a PHP function (basically skipping the user interface)?

This is a great plugin, Thank you!

Would I use these functions?

function set_link( $post_id, $url ) {
		return $this->flush_links_if( (bool) update_post_meta( $post_id, self::LINK_META_KEY, $url ) );
}


	/**
	 * Tell an custom URL post to open in a new tab
	 *
	 * @param int $post_id post ID
	 * @return bool whether anything changed
	 */
function set_link_new_tab( $post_id ) {
		return $this->flush_targets_if( (bool) update_post_meta( $post_id, self::TARGET_META_KEY, '_blank' ) );
}

Apply only on specific Post Types

I use this plugin in many sites. Great work @markjaquith !

My problem is that in sites with multiple Post Types I see the metabox in all the post types although I need it only in one Post Type.

Any chance the plugin will have a setting page with a list of available Post Types where the user can select in which Post Types the metabox should be displayed?

wordpress

metabox title and notice text should use "...{$post_type_obj->labels->singular_name}..." instead of "...Page..."

Since Page Links To works for all post_types for which 'show_ui' => true (and not just pages), the title of the metabox and the text in the notice should use the singular_name label of the post_type in question, instead of always using "...Page...", as it could be "disconcerting" to admin users who are editing a "Movie", etc and see something on screen that mentions "Page".

Attached is a patch that accomplishes this.

Two things to note about this patch:

  1. there should be some error checking on the return value(s) of the 2 calls to get_post_type_object()...I'll leave that to you :-)
  2. the change in notify_of_external_link() relies on the WP global $typenow. I couldn't figure out a way to pass the current post to that func...maybe you can

patch.zip

Gutenberg Support?

When editing a page with Gutenberg, the Page Links To metabox does not appear:

screenshot

Editing the same page with the Classic Editor displays the metabox:

screenshot

Override HTTPS linking

When I access my wordpress site in http, the Page Links To url works as expected - it redirects to the set custom url, http://theSpecificiedUrl

When I access the main site in https, the Page Link To url is automatically changed to link to https://theSpecificiedUrl

I understand this is probably working as designed, is there a way to override this? A way to have that particular link always point to an http endpoint, no matter how the original site is accessed?

Enhancement Request

Would there be anyway to allow for assignment of a CSS class to the redirect link?

For Example

Current link

<a target="_blank" href="http://compuaidusa.com/?p=239&amp;content-only=1&amp;css=1&amp;width=600&amp;height=550" title="Entertainment">Entertainment</a>

Link with class

<a class="thickbox" target="_blank" href="http://compuaidusa.com/?p=239&amp;content-only=1&amp;css=1&amp;width=600&amp;height=550" title="Entertainment">Entertainment</a>

This will enable the ability to open posts in a Thickbox or Fancybox directly from a list of posts in a megamenu.

Is there a realistic possibility this enhancement could be incorporated?

Thanks very much for this fine plugin!

Only show MetaBox on "Public" post types?

It looks like you're defaulting to using post_types that have 'show_ui' true. I was wondering if you thought about also adding the restriction that they must also be 'public' post types.

I'm struggling to come up with a use case where I'd want to use page_links_to for a non-public post type - and am actually wondering if it's even possible!

I'm currently using the page-links-to-post-types filter to hide it on my CPT, but it just seems like that should be the default behavior for non-public CPTs.

thanks!

Link to "nothing"

Sometimes people want, for various reasons, links to do nothing. They can just put in # but we could handle this more elegantly with a JavaScript onClick event.

ob_end_flush Error

There was an error with WordFence caching and your plugin. Your plugin was throwing this error when WordFence created a cached page.

<b>Notice</b>: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in <b>/home/coursev/public_html/wp-content/plugins/page-links-to/page-links-to.php</b> on line <b>152</b>

I resolved it by changing this on line 148:

/**
* Flushes the buffer
*/
function end_buffer() {
//ob_end_flush();
if ( ob_get_level() > 1 ) {
ob_end_flush();
}
}

Can you please make a update to your program to get this fixed? Thanks.

v3.0.0 Crashes sites

https://wordpress.org/support/topic/ver-3-0-crashes-wordpress/#post-10530144

Stack trace:
#0 /home/derry/public_html/wp-includes/class-wp-hook.php(286): CWS_PageLinksTo->wp_list_pages(‘\t<li class=”men…’, Array)
#1 /home/derry/public_html/wp-includes/plugin.php(203): WP_Hook->apply_filters(‘\t<li class=”men…’, Array)
#2 /home/derry/public_html/wp-content/themes/Derry/library/navigation.php(325): apply_filters(‘wp_list_pages’, ‘\t<li class=”men…’, Array)
#3 /home/derry/public_html/wp-content/themes/Derry/library/navigation.php(191): theme_MenuWalker->walk(Array, Array)
#4 /home/derry/public_html/wp-content/themes/Derry/library/navigation.php(27): theme_get_list_pages(Array)
#5 /home/derry/public_html/wp-content/themes/Derry/library/widgets.php(142): theme_get_menu(Array)
#6 /home/derry/public_html/wp-include in /home/derry/public_html/wp-content/plugins/page-links-to/classes/plugin.php on line 650
[26-Jul-2018 00:24:39 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function CWS_PageLinksTo::wp_list_pages(), 2 passed in /home/derry/public_html/wp-includes/class-wp-hook.php on line 286 and exactly 3 expected in /home/derry/public_html/wp-content/plugins/page-links-to/classes/plugin.php:650

Support multi-lingual redirects

Many people have written me asking for support for language-specific redirects, when using multi-language plugins. There seems like enough demand to justify it.

Tasks:

  • figure out what the most popular ML plugins are
  • determine which of those I want to support
  • when one of them is active, add the ability to add additional redirects that are tied to a language
  • on load and redirect, determine which language is active through the ML plugin, and rewrite or redirect appropriately

Respect the "Open link in new window" setting no matter where the link appears.

Currently, the "Open link in new window" setting only works within nav menus wp_list_page() and then within the post loop. But there are other places it can appear, such as in plugin or theme custom output. It is a very common complaint.

New proposed strategy: keep track of each time that one of the URLs is replaced in a get_the_permalink() filter callback, and then in the footer, do new window JS output for all those.

Find a better way of opening links in a new tab

I'm tired of having to support themes that load async content or something else and thus skip being noticed by PLT and links don't open in a new tab when specified.

The issue is that all I have control over is the URL output. I can't add a class or anything. And if I do something clever like use a fake protocol or add a URL parameter, that will interfere with SEO for that URL.

One option is to skip the logging, and always output the full array of "new tab" URLs. But that'll bloat the page if you have a huge number of "in a new tab" links. And it'll slow it down doing all those checks.

One thing I could do is append #new_tab to the end of the URL, and then have code that on load, removes that, and makes the links open on a new tab. And then I could monitor clicks on the fly to deal with content added after the fact. Google ignore hash fragments in URLs by default.

Conflict with Elementor, Page Links to, and Wordpress 5.1

Hi there Mark,

I'm trying to use 'Page Links To' to link to external URL's instead of default post internal url's. It all works, however when I attempt to edit the post with Elementor it will only open in what they call 'Safe Mode.'

Do you know if this would be a conflict between Elementor and Page Links To, or conflict between Page Links To and Wordpress 5.1

Thanks....

Norm Prosser
[email protected]

Optimizing .php file disables the new tab option on posts

I recently was optimizing my website's database and cleared out an old plugin table "wp_popularpostsummary" in PHPMYADMIN. However, after I dropped that table my links were no longer redirecting readers to new tabs. It seems as though my "open link in new tab" button is no longer working for our posts.

Link to existing posts/pages

Hey and thanks for this great plugin. Do you think its possible to add an extra option/dropdown to link to existing post/posttypes and pages? Just as the linkoption in WYSIWYG does?
Best, Mike

The 'page-links-to-post-types' filter returns an error.

Hi,

I have a Custom Post type that I’d like to include the PLT plugin while excluding all other post types.

This is the filter I’m using:

add_filter( 'page-links-to-post-types', array_keys( get_post_types( array( 'name' => 'nymc_press_articles', 'show_ui' => true ) ) ) );

And it returns this error:

Notice: Undefined offset: 0 in /home/area17/public_html/dev.area17.com/nycmc/wp-includes/plugin.php on line 787 Notice: Undefined offset: 0 in /home/area17/public_html/dev.area17.com/nycmc/wp-includes/plugin.php on line 805 Warning: call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members in /home/area17/public_html/dev.area17.com/nycmc/wp-includes/plugin.php on line 199 Warning: in_array() expects parameter 2 to be array, null given in /home/area17/public_html/dev.area17.com/nycmc/wp-content/plugins/page-links-to/page-links-to.php on line 215 Warning: call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members in /home/area17/public_html/dev.area17.com/nycmc/wp-includes/plugin.php on line 199 Warning: in_array() expects parameter 2 to be array, null given in /home/area17/public_html/dev.area17.com/nycmc/wp-content/plugins/page-links-to/page-links-to.php on line 215 Warning: call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members in /home/area17/public_html/dev.area17.com/nycmc/wp-includes/plugin.php on line 199 Warning: in_array() expects parameter 2 to be array, null given in /home/area17/public_html/dev.area17.com/nycmc/wp-content/plugins/page-links-to/page-links-to.php on line 215

I also get the same error when I use the filter copied from the plugin, itself:

add_filter( 'page-links-to-post-types', array_keys( array( 'nymc_press_articles' ) ) );

Any ideas what might be causing this?

Thanks!

Problems in Setting Up Twitter Card

I love this plugin because I run a news aggregator site that uses algorithms to pull together all the relevant articles around a specific development. I then write custom summaries based on all the articles, but assign the best article as the lead and give it the page-links-to link.

However, in trying to set up a twitter card for my blog posts, I need to point to a permalink that references my specific blog post in order for the twitter card to work for individual posts.

Can you recommend a method for doing this? I'm having trouble. If I construct a URL that says www.example.com/date/post id, I can go directly to my blog post in a browser. I should be able to do the same thing for Twitter cards.

Do I need to create a filter to do this? Any suggestions would be greatly appreciated.

Thank you so much!

Change default cws_links_to value to placeholder text?

The meta box auto populates the cws_links_to field with "http://" when the field is empty. I understand this is a helpful reminder for people to include http://, but it always has to be deleted unless you are manually typing out an absolute URL. We have had a few cases of someone copying and pasting a full URL (which will typically already includes the protocol) and forgetting to delete the default http:// text. Of course this breaks the URL.

What are your thoughts on setting "http://" as the placeholder attribute on the input rather than the default value? I'm happy to PR if you think this would make sense.

FLIP THE HELL OUT when something else loads an unexpected version of jQuery

I'm really sick of fielding support requests for sites where some dumb theme or widget or plugin has loaded a 4-year-old version of jQuery. Considering adding code to detect this. But what do I do if I detect it? Do an alert() on load? Would be super annoying, but then again loading the wrong version of jQuery is a pretty serious problem.

Redirects in RSS Feeds

Plugin works great to send visitors to external links but when the link shows up in an RSS feed, the links break. If mysite.com's post linked to someothersite.com/article then in the RSS feed, the link goes to mysite.com/article.
Has anyone else experienced this?

Custom URL Not Available

I have seen this issue randomly (along with several other Admins) where the custom URL field does not show even when the correct radio button is selected.

The issue seems to be related to specific posts as I can see the custom URL field on one post and it is missing on another. Tried different browsers and different admin user/computers and same result. Any ideas?

Latest version of plugin installed and Wordpress 4.4.1 installed.

img_25012016_102550

My email

Hey, I sent you a Google Forms about feature requests and didnt give you my email to beta test. Thanks for building this plugin and keeping it active!

[email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.