Skip to content

Commit

Permalink
Merge branch 'release-0.8.0' into releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Archetyped committed Nov 4, 2022
2 parents 4f902b7 + a76e856 commit 76914ca
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 47 deletions.
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/0_support-ticket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Support Ticket
about: Get support for an issue you are experiencing
title: ""
labels: support
assignees: ''

---

## Description of Problem

(Clearly describe the issue you are experiencing here, and fill in the necessary details below)

## Details

* URL of Page exhibiting problem:
* Browser(s) exhibiting problem (Firefox, Chrome, etc.):
* Version of CNR Installed:
* Other plugins installed:
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/1_feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Enhance! Suggest a new feature for CNR.
title: "[Request]: "
labels: enhancement
assignees: ''

---

## Description of feature

(Describe your feature or idea here)

## This feature would be used to

(Describe usage here)

## If you added this feature, I would:

a) Eat my hat
b) Jump for joy
c) Shave my cat
d) All of the above
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Support & Feedback
url: https://github.com/archetyped/cornerstone/wiki/Support-&-Feedback
about: How to get support and share feedback for Cornerstone
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/feedback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Feedback
about: Share your feedback
title: "[Feedback]: "
labels: feedback
assignees: ''

---


5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.ds_store
.vscode
.sass-cache
node_modules/
vendor/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Cornerstone transforms WordPress into a full-fledged Content Management System.
## Support
Found a bug or otherwise experiencing an issue with Cornerstone? [Report the issue here][issue-report]

[issue-report]: https://github.com/archetyped/cornerstone/wiki/Reporting-Issues "Report an issue"
[issue-report]: https://github.com/archetyped/cornerstone/wiki/Support-&-Feedback "Report an issue"
[home]: http://archetyped.com/tools/cornerstone/ "Cornerstone home page"
34 changes: 18 additions & 16 deletions includes/class.utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,34 +847,36 @@ function get_plugin_textdomain() {
* @param mixed $default (optional) Default action if no action exists
* @return string Current action
*/
function get_action($default = null) {
function get_action( $default = null ) {
$action = '';
//Check if action is set in URL
if ( isset($_GET['action']) )

// Check if action is set in URL
if ( isset( $_GET['action'] ) ) {
$action = $_GET['action'];
//Otherwise, Determine action based on plugin plugin admin page suffix
elseif ( isset($_GET['page']) && ($pos = strrpos($_GET['page'], '-')) && $pos !== false && ( $pos != count($_GET['page']) - 1 ) )
$action = trim(substr($_GET['page'], $pos + 1), '-_');
} elseif ( isset( $_GET['page'] ) && ( $pos = strrpos( $_GET['page'], '-' ) ) && $pos !== false && ( $pos != strlen( $_GET['page'] ) - 1 ) ) {
// Otherwise, Determine action based on plugin admin page suffix
$action = trim( substr( $_GET['page'], $pos + 1 ), '-_' );
}

//Determine action for core admin pages
if ( ! isset($_GET['page']) || empty($action) ) {
// Determine action for core admin pages
if ( ( ! isset( $_GET['page'] ) || empty( $action ) ) && isset( $_SERVER['SCRIPT_NAME'] ) ) {
$actions = array(
'add' => array('page-new', 'post-new'),
'edit-item' => array('page', 'post'),
'edit' => array('edit', 'edit-pages')
'add' => array( 'page-new', 'post-new' ),
'edit-item' => array( 'page', 'post' ),
'edit' => array( 'edit', 'edit-pages' ),
);
$page = basename($_SERVER['SCRIPT_NAME'], '.php');
$page = basename( $_SERVER['SCRIPT_NAME'], '.php' );

foreach ( $actions as $act => $pages ) {
if ( in_array($page, $pages) ) {
if ( in_array( $page, $pages ) ) {
$action = $act;
break;
}
}
}
if ( empty($action) )
if ( empty( $action ) ) {
$action = $default;
}
return $action;
}

Expand Down
122 changes: 98 additions & 24 deletions js/lib.structure.admin.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,120 @@
/**
* Structure Administration
* @package Cornerstone
* @subpackage Structure
* @subpackage Structure
*/

(function($) {

if ( CNR && CNR.structure && CNR.structure.extend ) CNR.structure.extend('admin', {
parent: CNR.structure,
options: {},

manage_option: function() {
//Continue processing if permalink option has been defined
if ( this.options && this.options.label && this.options.example && this.parent.options.permalink_structure ) {
const opts = this.options;
opts.parent = this.parent.options;
var o = this.options;
var po = this.parent.options;
//Get options table
var opts_list = $('.wrap .form-table tbody:first');
var rows = $(opts_list).find('tr');
//Insert custom option
if (rows.length) {
var last = $(rows).get(rows.length - 1);
var option = $(opts_list).find('tr:first').clone();
var input = $(option).find('input');
//Input
$(input).val(po.permalink_structure);
if (po.permalink_structure == $('#permalink_structure').val()) {
$(input).attr('checked', 'checked');
// Options handling (WP 6.1+)
const cfg = {
selectors: {
match: '.structure-selection',
template: '.structure-selection > .row',
input: 'input[type="radio"]',
label: 'label',
example: 'p > code',
},
elements: {
template: null,
base: null,
input: null,
label: null,
example: null,
custom: document.getElementById( 'permalink_structure' ),
},
values: {
id_base: 'cnr-structured',
},
legacy: {
selectors: {
template: '.permalink-structure tr',
input: 'input[type="radio"]',
label: 'label',
example: 'td > code',
},
},
};
// Set up values
cfg.values.input_id = 'permalink-input-' + cfg.values.id_base;
cfg.values.example_id = 'permalink-' + cfg.values.id_base;
// Determine if legacy configuration should be used.
if ( !document.querySelector(cfg.selectors.match) ) {
let prop;
for ( prop in cfg.legacy ) {
cfg[ prop ] = cfg.legacy[ prop ];
}
}
// Reference elements object.
const els = cfg.elements;
// Retrieve single structure option to use as template for custom option.
els.template = document.querySelector( cfg.selectors.template );
// Stop if option not found.
if ( !els.template ) {
return false;
}
// Clone option element.
els.base = els.template.cloneNode( true );
// Input element.
els.input = els.base.querySelector( cfg.selectors.input );
if ( !els.input ) {
return false;
}
els.input.setAttribute( 'id', cfg.values.input_id );
els.input.setAttribute( 'value', opts.parent.permalink_structure );
if ( els.custom ) {
if ( els.custom.value === opts.parent.permalink_structure ) {
els.input.setAttribute( 'checked', 'checked' );
} else {
$(input).removeAttr('checked');
els.input.removeAttribute( 'checked' );
}
// Event handler (option selected).
els.input.addEventListener('change', function() {
if ( els.custom.value === this.value ) {
return false;
}
els.custom.value = this.value;
});
}
// Label element.
els.label = els.base.querySelector( cfg.selectors.label );
if ( els.label ) {
// Attributes.
els.label.setAttribute( 'for', els.input.getAttribute( 'id' ) );
// Text.
// Fallback: Set text for label element directly.
let labelNode = els.label;
// Update text node within label element.
if ( els.label.childNodes.length > 1 ) {
// Get first text node.
let childNode = Array.from( els.label.childNodes ).find( cnode => cnode.nodeType === Node.TEXT_NODE );
if ( childNode ) {
labelNode = childNode;
}
}
//Label
var label = $(option).find('label');
//Move input element out of label element
$(label).text(o.label).prepend(input);
//Example text
$(option).find('td code').text(o.example);
//Insert element before last option in table
$(last).before($(option));
labelNode.textContent = labelNode.textContent.replace(/^(\s*)(\S.+?)(\s*)$/i, `\$1${opts.label}\$3`);
}
// Example permalink element.
els.example = els.base.querySelector( cfg.selectors.example );
if ( els.example ) {
els.example.setAttribute( 'id', cfg.values.example_id );
els.example.textContent = opts.example;
}
// Insert option into list.
els.template.parentNode.insertBefore( els.base, els.template );
}
}
}
});

if ( CNR.structure.admin.manage_option )
Expand Down
6 changes: 3 additions & 3 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
*
* @package Cornerstone
* @author Archetyped <[email protected]>
* @copyright 2020 Archetyped
* @copyright 2022 Archetyped
*
* Plugin Name: Cornerstone
* Plugin URI: http://archetyped.com/tools/cornerstone/
* Description: Enhanced content management for WordPress
* Version: 0.7.7
* Version: 0.8.0
* Requires at least: 5.3
* Text Domain: cornerstone
* Author: Archetyped
* Author URI: http://archetyped.com
* Support URI: https://github.com/archetyped/cornerstone/wiki/Reporting-Issues
* Support URI: https://github.com/archetyped/cornerstone/wiki/Support-&-Feedback
*/

$cnr = null;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cornerstone",
"version": "0.7.7",
"version": "0.8.0",
"title": "Cornerstone",
"description": "Enhanced content management for WordPress",
"author": "Archetyped <[email protected]>",
Expand Down
12 changes: 10 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate: https://gum.co/cnr-donate
Tags: cornerstone, cms, content, management, system, structure, organization, sections
Plugin Link: http://archetyped.com/tools/cornerstone/
Requires at least: 5.3
Tested up to: 5.3
Tested up to: 6.0
Stable tag: trunk

Enhanced content management for WordPress
Expand Down Expand Up @@ -50,7 +50,7 @@ No upgrade notices

== Frequently Asked Questions ==

Post your questions/comments at [Cornerstone's official issue tracker](https://github.com/archetyped/cornerstone/wiki/Reporting-Issues).
Post your questions/comments at [Cornerstone's official issue tracker](https://github.com/archetyped/cornerstone/wiki/Support-&-Feedback).

== Screenshots ==

Expand All @@ -60,6 +60,14 @@ Post your questions/comments at [Cornerstone's official issue tracker](https://g

== Changelog ==

= 0.8.0 =

* Update: Custom permalink structure option integration for WordPress 6.1+.

= 0.7.8 =

* Fix: Utilities: `count()` used on non-Countable value. (props @nikelaos)

= 0.7.7 =

* Fix: Spelling.
Expand Down

0 comments on commit 76914ca

Please sign in to comment.