Frontier Post – Edit Link
WordPress offers a link to edit your own posts & pages (or for admins all posts & pages) in the front end. The link is shown in the admin bar and on the post itself. This link will redirect the user to the edit form in the backend. Visibility of the edit link on the post can be different based on your theme (some theme doesn’t even show it) – Below screenshot of the edit link from Twenty Sixteen theme (link on the right side):
Frontier Post changes this link and the Admin Bar link to redirect to the Frontier Post edit form, using the get_edit_post_link filter, based on the capability settings.
The following rules apply:
- If the link i called from the admin area (backend) the url is not changed
- If user is Super Admin and if edit link for Super Admin is not enabled for the post type***, the url is not changed
- If the posts type is different from post or page, the url is not changed
- If post type is page and user does not have capability “frontier_post_can_page”, the url is not changed
- If the user does not have capability “frontier_post_redir_edit” (Edit Link), the url is not changed
- If none of the above conditions kicks in, the url is changed to Frontier Post edit form (the page that is set in Frontier Post settings: Page containing (frontier-post) shortcode.
*The above only apply to the link, once a user clicks on the link (or Edit Post in the Admin Bar), the “normal” validations of Frontier Post kicks in.
** The above only applies to the standard WordPress edit links, not the links from the Frontier Posts interface.
*** As capability check always will return true for Super Admins (multisite), there is a new setting in Frontier Post advanced settings, where you can specify which post types should redirect to Frontier Post, as opposed to the backend:
Frontier Post capabilities – For all users (except Super Admins) the edit link can be controlled by “Edit Link” and Can Pages”:
Code:
//******************************************************************************************* // Redirect standard link for edit post from backend (admin interface) to frontend //******************************************************************************************* function frontier_edit_post_link( $url, $post_id ) { // Do not change edit link if called from admin panel if ( is_admin() && strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-admin' ) !== false) return $url; $tmp_post_type = get_post_type($post_id); // Do not change edit link if not page or post if ( !in_array($tmp_post_type, array("post", "page")) ) return $url; // Check specific settings for super admin (multisite) if ( current_user_can('manage_network_options' ) ) { $tmp_sadmin_types = fp_get_option_array('fps_sc_super_admin_types'); if ( !in_array($tmp_post_type, $tmp_sadmin_types) ) return $url; } // Do not change edit link if page and user camt edit page using Frontier Post if ( $tmp_post_type == "page" && !current_user_can('frontier_post_can_page') ) return $url; if ( current_user_can( 'frontier_post_redir_edit' ) ) { $frontier_edit_page = (int) fp_get_option('fps_page_id'); $url = ''; $concat= get_option("permalink_structure")?"?":"&"; //set the permalink for the page itself $frontier_permalink = get_permalink($frontier_edit_page); $url = $frontier_permalink.$concat."task=edit&postid=".$post_id; } return $url; } add_filter( 'get_edit_post_link', 'frontier_edit_post_link', 10, 2 );
Comments
Frontier Post – Edit Link — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>