Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seb86 committed Dec 3, 2018
1 parent 8a635a9 commit 58238f6
Show file tree
Hide file tree
Showing 14 changed files with 2,700 additions and 133 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/.* export-ignore
CHANGELOG.md export-ignore
CODE_OF_CONDUCT.md export-ignore
CONTRIBUTING.md export-ignore
Gruntfile.js export-ignore
package.json export-ignore
Expand Down
File renamed without changes
Binary file added .wordpress-org/assets/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md → CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contribute To Attachment Slug
# Contribute To Attachment Slugs

Community made patches, bug reports and contributions are always welcome and are crucial.

Expand All @@ -12,7 +12,7 @@ GitHub is for *bug reports and contributions only* - if you have a support quest

* Make sure you have a [GitHub account](https://github.com/signup/free)
* Submit a ticket for your issue, assuming one does not already exist.
* https://github.com/seb86/Attachment-Slug/issues
* https://github.com/seb86/attachment-slugs/issues
* Clearly describe the issue including steps to reproduce when it is a bug.
* Make sure you fill in the earliest version that you know that has the issue.

Expand Down
32 changes: 29 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

// Generate .pot file
makepot: {
target: {
options: {
cwd: '',
domainPath: 'languages', // Where to save the POT file.
exclude: [
'releases',
'node_modules',
],
mainFile: '<%= pkg.name %>.php', // Main project file.
potComments: '# Copyright (c) {{year}} Sébastien Dumont', // The copyright at the beginning of the POT file.
potFilename: '<%= pkg.name %>.pot', // Name of the POT file.
potHeaders: {
'poedit': true, // Includes common Poedit headers.
'x-poedit-keywordslist': true, // Include a list of all possible gettext functions.
'Report-Msgid-Bugs-To': 'https://github.com/seb86/attachment-slugs/issues',
'language-team': 'Sébastien Dumont <mailme@sebastiendumont.com>',
'language': 'en_US'
},
type: 'wp-plugin', // Type of project.
updateTimestamp: true, // Whether the POT-Creation-Date should be updated without other changes.
}
}
},

// Check strings for localization issues
checktextdomain: {
options:{
text_domain: '<%= pkg.name %>', // Project text domain.
Expand Down Expand Up @@ -64,7 +91,7 @@ module.exports = function(grunt) {
replacements: [
{
from: /Stable tag:.*$/m,
to: "Stable tag: <%= pkg.version %>"
to: "Stable tag: <%= pkg.version %>"
},
{
from: /Version:.*$/m,
Expand All @@ -88,12 +115,11 @@ module.exports = function(grunt) {
'!.*/**',
'!.htaccess',
'!Gruntfile.js',
'!package.json',
'!package-lock.json',
'!releases/**',
'!node_modules/**',
'!.DS_Store',
'!npm-debug.log',
'!*.json',
'!*.sh',
'!*.zip',
'!*.jpg',
Expand Down
39 changes: 29 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,55 @@
# Attachment Slugs for WordPress

**Contributors:** sebd86
**Tags:** attachment, attachments, attachment slug, page slug, image slug, image url, permalinks, custom permalinks, seo
**Donate link:** https://www.paypal.me/codebreaker
**Tags:** attachment, attachments, attachment slug, page slug, image slug, image url, permalinks, custom permalinks
**Requires at least:** 4.4
**Tested up to:** 4.9.8
**Tested up to:** 5.0.0
**Requires PHP:** 5.6
**Stable tag:** 0.0.3
**Stable tag:** 1.0.0
**License:** GPL v2 or later

###### Follow me
💻 [Website](https://sebastiendumont.com) 🐦[Twitter](https://twitter.com/sebd86)


## Overview 🔔
## 🔔 Overview

Enables you to add permalink support for media attachments making the attachment URLs more friendly and great for SEO results.
Enables WordPress to allow attachments to have their own permalink structure. This makes the URLs more friendly and great for SEO results should you decide to index your attachments.

You can also edit the permalink slug of an indvidual attachment which you can not do via _Quick Edit_ like other post types. Changing the attachment title does not update the permalink slug so this handy to have should you want to rename the URL for the attachment.

#### Requirements ✅

#### ✅ Requirements

To use this plugin you will need:

* WordPress v4.4+
* PHP v5.6+

#### 💽 Installation

###### Manual
1. Download a `.zip` file with the [latest version](https://github.com/seb86/attachment-slugs/releases).
2. Go to **WordPress Admin > Plugins > Add New**.
3. Click **Upload Plugin** at the top.
4. **Choose File** and select the `.zip` file you downloaded in **Step 1**.
5. Click **Install Now** and **Activate** the plugin.

###### Automatic
1. Go to **WordPress Admin > Plugins > Add New**.
2. Search for **Attachment Slugs**
3. Click **Install Now** on the plugin and **Activate** the plugin.


#### Screenshot
![Permalink Options for Attachments](https://raw.githubusercontent.com/seb86/Attachment-Slug/master/screenshot-1.png)
#### Screenshots
![Permalink Options for Attachments](https://raw.githubusercontent.com/seb86/attachment-slugs/master/.wordpress-org/assets/screenshot-1.png)

![Edit Attachment Slug](https://raw.githubusercontent.com/seb86/attachment-slugs/master/.wordpress-org/assets/screenshot-2.png)

#### Reporting Issues 📝
#### 📝 Reporting Issues

If you think you have found a bug in the extension, please [open a new issue](https://github.com/seb86/Attachment-Slug/issues/new) and I will do my best to help you out.
If you think you have found a bug in the extension, please [open a new issue](https://github.com/seb86/attachment-slugs/issues/new) and I will do my best to help you out.


## Contribute
Expand Down
26 changes: 12 additions & 14 deletions permalink-settings.php → admin/class-as-permalink-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,35 @@
/**
* Adds settings to the permalinks admin settings page.
*
* @class AS_Admin_Permalink_Settings
* @author Sébastien Dumont
* @category Admin
* @package Attachment Slug/Admin
* @version 0.0.2
* @since 0.0.1
* @version 1.0.0
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( ! class_exists( 'AS_Admin_Permalink_Settings' ) ) {
if ( ! class_exists( 'Attachment_Slug_Admin_Permalink_Settings' ) ) {

class AS_Admin_Permalink_Settings {
class Attachment_Slug_Admin_Permalink_Settings {

/**
* Constructor
*/
public function __construct() {
$this->settings_init();
$this->settings_save();
}
} // END __construct()

/**
* Initilize the settings.
* Add a section to the permalinks page.
*
* @access public
*/
public function settings_init() {
// Add a section to the permalinks page
add_settings_section( 'attachment-permalink', __( 'Attachment Permalink', 'attachment-slug' ), array( $this, 'settings' ), 'permalink' );
} // END settings_init()

Expand All @@ -43,9 +41,9 @@ public function settings_init() {
* @param string|array $var
* @return string|array
*/
public function ac_as_clean( $var ) {
return is_array( $var ) ? array_map( 'ac_as_clean', $var ) : sanitize_text_field( $var );
} // END ac_as_clean()
public function aswp_as_clean( $var ) {
return is_array( $var ) ? array_map( 'aswp_as_clean', $var ) : sanitize_text_field( $var );
} // END aswp_as_clean()

/**
* Show the settings.
Expand All @@ -56,7 +54,7 @@ public function settings() {
echo wpautop( __( 'These settings control the permalink used specifically for attachments.', 'attachment-slug' ) );

$attachment_permalink = get_option( 'attachment_permalink' );
$base_slug = apply_filters('ac_as_base_slug', 'image');
$base_slug = apply_filters( 'aswp_as_base_slug', 'image' );

$structures = array(
0 => '',
Expand Down Expand Up @@ -126,13 +124,13 @@ public function settings_save() {
}

// Attachment base
$attachment_permalink = self::ac_as_clean( $_POST['attachment_permalink'] );
$attachment_permalink = self::aswp_as_clean( $_POST['attachment_permalink'] );

$permalink['custom'] = false;

if ( $attachment_permalink == 'custom' ) {
// Get permalink without slashes
$attachment_permalink = trim( self::ac_as_clean( $_POST['attachment_permalink_structure'] ), '/' );
$attachment_permalink = trim( self::aswp_as_clean( $_POST['attachment_permalink_structure'] ), '/' );

// Prepending slash
$attachment_permalink = '/' . $attachment_permalink;
Expand All @@ -153,4 +151,4 @@ public function settings_save() {

} // END if class exists

return new AS_Admin_Permalink_Settings();
return new Attachment_Slug_Admin_Permalink_Settings();
19 changes: 19 additions & 0 deletions admin/view/html-notice-requirement-wp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Admin View: WordPress Requirment Notice.
*
* @since 1.0.0
* @author Sébastien Dumont
* @category Admin
* @package Attachment Slug/Admin/Views
* @license GPL-2.0+
*/

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="notice notice-error">
<p><?php echo sprintf( __( 'Sorry, <strong>%s</strong> now requires WordPress %s or higher. Please upgrade your WordPress setup.', 'attachment-slug' ), esc_html__( 'Attachment Slug', 'attachment-slug' ), '4.4' ); ?></p>
</div>
Loading

0 comments on commit 58238f6

Please sign in to comment.