Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.project
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>post-types-order</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions css/cpt-archive-dd.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#the-list.ui-sortable tr:hover { cursor: move;}
#the-list.ui-sortable tr.alternate { background-color: #F9F9F9; }
#the-list.ui-sortable tr.ui-sortable-helper { background-color: #ffffff; outline: 1px solid #dfdfdf;}
23 changes: 12 additions & 11 deletions css/cpt.css
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#order-post-type #sortable { list-style-type: none; margin: 10px 0 0; padding: 0; width: 100%; }
#order-post-type #sortable ul { margin-left:20px; list-style: none; }
#order-post-type #sortable li { padding: 2px 0px; margin: 4px 0px; border: 1px solid #DDDDDD; cursor: move; -moz-border-radius:6px; background-color: #f9f9f9;}
#order-post-type #sortable li { padding: 7px 10px; margin: 4px 0px; border: 1px solid #DDDDDD; cursor: move; -moz-border-radius:6px; background-color: #f9f9f9;}
#order-post-type #sortable li:nth-child(2n+1) { background-color: #fff !important;}
#order-post-type #sortable li span { display: block; padding: 5px 10px; color:#555; font-size:13px;}
#order-post-type #sortable li.placeholder{border: dashed 2px #ccc;height:25px; background-color: #FFF;}
#order-post-type #sortable li span { display: block; color:#555; font-size:13px;}
#order-post-type #sortable li.placeholder{border: dashed 2px #ccc;height:18px; background-color: #FFF;}

#icon-settings {background-image:url("../images/admin-icon-settings.gif");background-repeat:no-repeat;}
h2.subtitle {font-size: 15px; font-style: italic; font-weight: bold}
#cpto h2.subtitle {font-size: 15px; font-style: italic; font-weight: bold; padding-left: 0px}
.wrap .example { color: #666666; font-size: 11px; font-weight: bold}

#cpt_info_box {padding: 0 10px; border: 1px dashed #6aadcc; background-color: #FFF; margin-top: 10px;
#cpto #cpt_info_box {padding: 0 10px; border: 1px dashed #6aadcc; background-color: #FFF; margin-top: 10px;
-webkit-box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);
-moz-box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);
box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);}
#cpt_info_box p {font-size: 12px}
#cpt_info_box a {text-decoration: none}
#cpt_info_box #donate_form {float: right; padding: 10px 0 17px; text-align: center; width: 100%;}
#cpto #cpt_info_box a {text-decoration: none}
#cpto #p_socialize {padding: 20px 0px 20px 0}
#cpto #cpt_info_box #donate_form { padding: 20px 0 17px; text-align: center; width: 100%;}
.menu_pto {margin-right: 4px; display: inline; vertical-align: middle; margin-top: -1px;}

#p_right {float: right; width: 210px; background-color:#f5f5f5; border-left: 1px dashed #dedede; border-right: 1px dashed #dedede}
.p_s_item {float: right; padding: 0px 5px; margin-top: 15px; margin-bottom: 5px; }
.p_s_item.s_gp {padding-top: 2px; margin-left: 5px}
#cpto #p_right {float: right; width: 230px; background-color:#f5f5f5; border-left: 1px dashed #dedede; border-right: 1px dashed #dedede; margin-left: 10px; text-align: center;}
#cpto .p_s_item {float: none; padding: 0px 5px; margin: 0px; display: inline-block; vertical-align: middle;}
#cpto .p_s_item > iframe, #cpto .p_s_item > div {display: block}
#cpto .p_s_item.s_gp {padding-top: 0px; margin-left: 0px}

.clear {clear: both}
599 changes: 599 additions & 0 deletions include/class.cpto.php

Large diffs are not rendered by default.

279 changes: 279 additions & 0 deletions include/class.functions.php

Large diffs are not rendered by default.

171 changes: 171 additions & 0 deletions include/class.options.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?php


class CptoOptionsInterface
{

var $CPTO;


function __construct()
{

global $CPTO;

$this->CPTO = $CPTO;

}

function check_options_update()
{

$options = $this->CPTO->functions->get_options();

if (isset($_POST['form_submit']) && wp_verify_nonce($_POST['cpto_form_nonce'],'cpto_form_submit'))
{

$options['show_reorder_interfaces'] = (array) $_POST['show_reorder_interfaces'];
$options['show_reorder_interfaces'] = array_map( 'sanitize_key', $options['show_reorder_interfaces'] );

$options['capability'] = sanitize_key($_POST['capability']);

$options['autosort'] = isset($_POST['autosort']) ? intval($_POST['autosort']) : '';
$options['adminsort'] = isset($_POST['adminsort']) ? intval($_POST['adminsort']) : '';
$options['archive_drag_drop'] = isset($_POST['archive_drag_drop']) ? intval($_POST['archive_drag_drop']) : '';

$options['navigation_sort_apply'] = isset($_POST['navigation_sort_apply']) ? intval($_POST['navigation_sort_apply']) : '';

echo '<div class="updated fade"><p>' . __('Settings Saved', 'post-types-order') . '</p></div>';

update_option('cpto_options', $options);
update_option('CPT_configured', 'TRUE');

}

}


function plugin_options_interface()
{
$options = $this->CPTO->functions->get_options();

?>
<div id="cpto" class="wrap">
<div id="icon-settings" class="icon32"></div>
<h2><?php _e('General Settings', 'post-types-order') ?></h2>

<?php $this->CPTO->functions->cpt_info_box(); ?>

<form id="form_data" name="form" method="post">
<br />
<h2 class="subtitle"><?php _e('General', 'post-types-order') ?></h2>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" style="text-align: right;"><label><?php _e('Show / Hide re-order interface', 'post-types-order') ?></label></th>
<td>
<?php

$post_types = get_post_types();
foreach( $post_types as $post_type_name )
{
//ignore list
$ignore_post_types = array(
'reply',
'topic',
'report',
'status'
);

if(in_array($post_type_name, $ignore_post_types))
continue;

if(is_post_type_hierarchical($post_type_name))
continue;

$post_type_data = get_post_type_object( $post_type_name );
if($post_type_data->show_ui === FALSE)
continue;
?>
<p><label>
<select name="show_reorder_interfaces[<?php echo $post_type_name ?>]">
<option value="show" <?php if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] == 'show') {echo ' selected="selected"';} ?>><?php _e( "Show", 'post-types-order' ) ?></option>
<option value="hide" <?php if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] == 'hide') {echo ' selected="selected"';} ?>><?php _e( "Hide", 'post-types-order' ) ?></option>
</select> &nbsp;&nbsp;<?php echo $post_type_data->labels->singular_name ?>
</label><br />&nbsp;</p>
<?php } ?>
</td>
</tr>
<tr valign="top">
<th scope="row" style="text-align: right;"><label><?php _e('Minimum Level to use this plugin', 'post-types-order') ?></label></th>
<td>
<select id="role" name="capability">
<option value="read" <?php if (isset($options['capability']) && $options['capability'] == "read") echo 'selected="selected"'?>><?php _e('Subscriber', 'post-types-order') ?></option>
<option value="edit_posts" <?php if (isset($options['capability']) && $options['capability'] == "edit_posts") echo 'selected="selected"'?>><?php _e('Contributor', 'post-types-order') ?></option>
<option value="publish_posts" <?php if (isset($options['capability']) && $options['capability'] == "publish_posts") echo 'selected="selected"'?>><?php _e('Author', 'post-types-order') ?></option>
<option value="publish_pages" <?php if (isset($options['capability']) && $options['capability'] == "publish_pages") echo 'selected="selected"'?>><?php _e('Editor', 'post-types-order') ?></option>
<option value="switch_themes" <?php if (!isset($options['capability']) || empty($options['capability']) || (isset($options['capability']) && $options['capability'] == "switch_themes")) echo 'selected="selected"'?>><?php _e('Administrator', 'post-types-order') ?></option>
<?php do_action('pto/admin/plugin_options/capability') ?>
</select>
</td>
</tr>

<tr valign="top">
<th scope="row" style="text-align: right;"><label for="autosort"><?php _e('Auto Sort', 'post-types-order') ?></label></th>
<td>
<p><input type="checkbox" <?php checked( '1', $options['autosort'] ); ?> id="autosort" value="1" name="autosort"> <?php _e("If checked, the plug-in automatically update the WordPress queries to use the new order (<b>No code update is necessarily</b>)", 'post-types-order'); ?></p>
<p class="description"><?php _e("If only certain queries need to use the custom sort, keep this unchecked and include 'orderby' => 'menu_order' into query parameters", 'post-types-order') ?>.
<br />
<a href="http://www.nsp-code.com/sample-code-on-how-to-apply-the-sort-for-post-types-order-plugin/" target="_blank"><?php _e('Additional Description and Examples', 'post-types-order') ?></a></p>

</td>
</tr>


<tr valign="top">
<th scope="row" style="text-align: right;"><label for="adminsort"><?php _e('Admin Sort', 'post-types-order') ?></label></th>
<td>
<p>
<input type="checkbox" <?php checked( '1', $options['adminsort'] ); ?> id="adminsort" value="1" name="adminsort">
<?php _e("To affect the admin interface, to see the post types per your new sort, this need to be checked", 'post-types-order') ?>.</p>
</td>
</tr>

<tr valign="top">
<th scope="row" style="text-align: right;"><label for="archive_drag_drop"><?php _e('Archive Drag&Drop ', 'post-types-order') ?></label></th>
<td>
<p>
<input type="checkbox" <?php checked( '1', $options['archive_drag_drop'] ); ?> id="archive_drag_drop" value="1" name="archive_drag_drop">
<?php _e("Allow sortable drag & drop functionality within default WordPress post type archive. Admin Sort need to be active.", 'post-types-order') ?>.</p>
</td>
</tr>

<tr valign="top">
<th scope="row" style="text-align: right;"><label for="navigation_sort_apply"><?php _e('Next / Previous Apply', 'post-types-order') ?></label></th>
<td>
<p>
<input type="checkbox" <?php checked( '1', $options['navigation_sort_apply'] ); ?> id="navigation_sort_apply" value="1" name="navigation_sort_apply">
<?php _e("Apply the sort on Next / Previous site-wide navigation.", 'post-types-order') ?> <?php _e('This can also be controlled through', 'post-types-order') ?> <a href="http://www.nsp-code.com/apply-custom-sorting-for-next-previous-site-wide-navigation/" target="_blank"><?php _e('code', 'post-types-order') ?></a></p>
</td>
</tr>

</tbody>
</table>

<p class="submit">
<input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Settings', 'post-types-order') ?>">
</p>

<?php wp_nonce_field('cpto_form_submit','cpto_form_nonce'); ?>
<input type="hidden" name="form_submit" value="true" />


</form>

</div>
<?php

}
}

?>
54 changes: 54 additions & 0 deletions include/class.walkers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

class Post_Types_Order_Walker extends Walker
{

var $db_fields = array (
'parent' => 'post_parent',
'id' => 'ID'
);


function start_lvl(&$output, $depth = 0, $args = array())
{
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class='children'>\n";
}


function end_lvl(&$output, $depth = 0, $args = array())
{
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}


function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0)
{
if ( $depth )
$indent = str_repeat("\t", $depth);
else
$indent = '';

extract($args, EXTR_SKIP);

$item_details = apply_filters( 'the_title', $page->post_title, $page->ID );
$item_details = apply_filters('cpto/interface_itme_data', $item_details, $page);

$output .= $indent . '<li id="item_'.$page->ID.'"><span>'. $item_details .'</span>';



}


function end_el(&$output, $page, $depth = 0, $args = array())
{
$output .= "</li>\n";
}

}



?>
Loading