=' ) ) { add_action( 'admin_notices', array( $this, 'requirement_wp_notice' ) ); return false; } return true; } // END check_wp() /** * Show the WordPress requirement notice. * * @access public * @since 1.0.0 */ public function requirement_wp_notice() { include( dirname( __FILE__ ) . '/admin/views/html-notice-requirement-wp.php' ); } // END requirement_wp_notice() /** * Includes the permalink settings. * * @access public */ public function initialize_permalink_settings() { include_once( dirname( __FILE__ ) . '/admin/class-as-permalink-settings.php' ); } // END initialize_permalink_settings() /** * Filters the attachment links * * @access public * @return string $link */ public function attachment_link( $link, $post_id ){ $permalink = get_option( 'attachment_permalink' ); $attachment_slug = $permalink['base']; // Attachment base or custom base. if ( ! empty( $attachment_slug ) ) { $post = get_post( $post_id ); $link = home_url( '/' . $attachment_slug . '/' . $post->post_name . '/' ); } return $link; } // END attachment_link() /** * Add the Attachment Slug rewrite rule * * @access public * @return void */ public function add_rewrite_rule() { $permalink = get_option( 'attachment_permalink' ); $attachment_slug = trim( $permalink['base'], '/' ); // Attachment base or custom base. if ( ! empty( $attachment_slug ) ) { // Add the rewrite rule. add_rewrite_rule('^' . $attachment_slug . '/([^/]*)/?', 'index.php?attachment=$matches[1]', 'top'); } } // END add_rewrite_rule() /** * Make the plugin translation ready. * * Translations should be added in the WordPress language directory: * - WP_LANG_DIR/plugins/attachment-slug-LOCALE.mo * * @access public * @return void */ public function load_plugin_textdomain() { load_plugin_textdomain( 'attachment-slug', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); } // END load_plugin_textdomain() /** * Adds a text field to allow an individual attachment * to have a unique slug. * * @access public * @since 1.0.0 * @global object $post WP_Post * @return void */ public function individual_slug() { global $post; $slug = $post->post_name; echo '