PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-content
/
plugins
/
admin-site-enhancements
/
classes
<?php namespace ASENHA\Classes; /** * Class for External Permalinks module * * @since 6.9.5 */ class External_Permalinks { /** * Add external permalink meta box for enabled post types * * @since 3.9.0 */ public function add_external_permalink_meta_box( $post_type, $post ) { $options = get_option( ASENHA_SLUG_U, array() ); $enable_external_permalinks_for = $options['enable_external_permalinks_for']; foreach ( $enable_external_permalinks_for as $post_type_slug => $is_external_permalink_enabled ) { if ( ( get_post_type() == $post_type_slug ) && $is_external_permalink_enabled ) { // Skip adding meta box for post types where Gutenberg is enabled // if ( // function_exists( 'use_block_editor_for_post_type' ) // && use_block_editor_for_post_type( $post_type_slug ) // ) { // continue; // go to the beginning of next iteration // } add_meta_box( 'asenha-external-permalink', // ID of meta box 'External Permalink', // Title of meta box [ $this, 'output_external_permalink_meta_box' ], // Callback function $post_type_slug, // The screen on which the meta box should be output to 'normal', // context 'high' // priority // array(), // $args to pass to callback function. Ref: https://developer.wordpress.org/reference/functions/add_meta_box/#comment-342 ); } } } /** * Render External Permalink meta box * * @since 3.9.0 */ public function output_external_permalink_meta_box( $post ) { ?> <div class="external-permalink-input"> <input name="<?php echo esc_attr( 'external_permalink' ); ?>" class="large-text" id="<?php echo esc_attr( 'external_permalink' ); ?>" type="text" value="<?php echo esc_url( get_post_meta( $post->ID, '_links_to', true ) ); ?>" placeholder="https://" /> <div class="external-permalink-input-description">Keep empty to use the default WordPress permalink. External permalink will open in a new browser tab.</div> <?php wp_nonce_field( 'external_permalink_' . $post->ID, 'external_permalink_nonce', false, true ); ?> </div> <?php } /** * Save external permalink input * * @since 3.9.0 */ public function save_external_permalink( $post_id ) { // Only proceed if nonce is verified if ( isset( $_POST['external_permalink_nonce'] ) && wp_verify_nonce( $_POST['external_permalink_nonce'], 'external_permalink_' . $post_id ) ) { // Get the value of external permalink from input field $external_permalink = isset( $_POST['external_permalink'] ) ? esc_url_raw( trim( $_POST['external_permalink'] ) ) : ''; // Update or delete external permalink post meta if ( ! empty( $external_permalink ) ) { update_post_meta( $post_id, '_links_to', $external_permalink ); } else { delete_post_meta( $post_id, '_links_to' ); } } } /** * Change WordPress default permalink into external permalink for pages * * @since 3.9.0 */ public function use_external_permalink_for_pages( $permalink, $post_id ) { $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] ); // e.g. /wp-admin/index.php?page=page-slug if ( false === strpos( $request_uri, 'mfn-live-builder' ) ) { // When not in BeTheme template builder, that has the 'action=mfn-live-builder' parameter in the URL $external_permalink = get_post_meta( $post_id, '_links_to', true ); if ( ! empty( $external_permalink ) ) { $permalink = $external_permalink; } } return $permalink; } /** * Change WordPress default permalink into external permalink for posts and custom post types * * @since 3.9.0 */ public function use_external_permalink_for_posts( $permalink, $post ) { $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] ); // e.g. /wp-admin/index.php?page=page-slug if ( false === strpos( $request_uri, 'mfn-live-builder' ) ) { // When not in BeTheme template builder, that has the 'action=mfn-live-builder' parameter in the URL $external_permalink = get_post_meta( $post->ID, '_links_to', true ); if ( ! empty( $external_permalink ) ) { $permalink = $external_permalink; if ( ! is_admin() ) { $permalink = $permalink . '#new_tab'; } } } return $permalink; } /** * Redirect page/post to external permalink if it's loaded directly from the WP default permalink * * @since 3.9.0 */ public function redirect_to_external_permalink() { // If not on/loading the single page/post URL, do nothing if ( ! is_singular() ) { return; } global $post; if ( ! is_null( $post ) && is_object( $post ) && is_a( $post, 'WP_Post' ) ) { if ( property_exists( $post, 'ID' ) ) { $external_permalink = get_post_meta( $post->ID, '_links_to', true ); if ( ! empty( $external_permalink ) ) { wp_redirect( $external_permalink, 302 ); // temporary redirect exit; } } } } }
[-] class-hide-admin-bar.php
[edit]
[-] class-svg-upload.php
[edit]
[-] class-disable-gutenberg.php
[edit]
[-] class-cleanup-admin-bar.php
[edit]
[-] class-disable-rest-api.php
[edit]
[-] class-multiple-user-roles.php
[edit]
[-] class-disable-updates.php
[edit]
[-] class-image-upload-control.php
[edit]
[-] class-hide-admin-notices.php
[edit]
[-] class-content-duplication.php
[edit]
[-] class-insert-head-body-footer-code.php
[edit]
[-] class-media-replacement.php
[edit]
[-] class-password-protection.php
[edit]
[-] class-heartbeat-control.php
[edit]
[-] class-email-address-obfuscator.php
[edit]
[-] class-settings-sanitization.php
[edit]
[-] class-wp-config-transformer.php
[edit]
[-] class-content-order.php
[edit]
[-] class-custom-css.php
[edit]
[-] class-enhance-list-tables.php
[edit]
[-] class-login-logout-menu.php
[edit]
[-] class-search-engines-visibility.php
[edit]
[-] class-limit-login-attempts.php
[edit]
[-] class-disable-xml-rpc.php
[edit]
[-] class-common-methods.php
[edit]
[-] class-email-delivery.php
[edit]
[-] class-obfuscate-author-slugs.php
[edit]
[-] class-external-permalinks.php
[edit]
[-] class-wider-admin-menu.php
[edit]
[-] class-display-system-summary.php
[edit]
[-] class-admin-menu-organizer.php
[edit]
[-] class-redirect-fourofour.php
[edit]
[-] class-manage-robots-txt.php
[edit]
[-] class-site-identity-on-login-page.php
[edit]
[-] class-avif-upload.php
[edit]
[-] class-disable-comments.php
[edit]
[-] class-manage-ads-appads-txt.php
[edit]
[-] class-various-admin-ui-enhancements.php
[edit]
[-] class-admin-menu-svg-icon-mask.php
[edit]
[-] class-deactivation.php
[edit]
[-] class-activation.php
[edit]
[-] class-view-admin-as-role.php
[edit]
[-] class-maintenance-mode.php
[edit]
[-] class-custom-body-class.php
[edit]
[-] class-disable-dashboard-widgets.php
[edit]
[-] class-login-id-type.php
[edit]
[-] class-image-sizes-panel.php
[edit]
[-] class-redirect-after-login.php
[edit]
[-] class-settings-sections-fields.php
[edit]
[-] class-auto-publish-posts-with-missed-schedule.php
[edit]
[-] class-revisions-control.php
[edit]
[+]
..
[-] class-registration-date-column.php
[edit]
[-] class-disable-embeds.php
[edit]
[-] class-show-custom-taxonomy-filters.php
[edit]
[-] class-custom-nav-menu-items-in-new-tab.php
[edit]
[-] class-disable-feeds.php
[edit]
[-] class-captcha-protection.php
[edit]
[-] class-custom-admin-footer-text.php
[edit]
[-] class-change-login-url.php
[edit]
[-] class-last-login-column.php
[edit]
[-] class-settings-fields-render.php
[edit]
[-] class-disable-smaller-components.php
[edit]
[-] class-disable-author-archives.php
[edit]
[-] class-redirect-after-logout.php
[edit]
[-] class-open-external-links-in-new-tab.php
[edit]