Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial support for sticky posts

  • Loading branch information...
commit 970641da9c4e1c7b0b3bad2827cd11c74eaea732 1 parent 91df125
@alexkingorg alexkingorg authored
Showing with 38 additions and 0 deletions.
  1. +38 −0 utility.php
View
38 utility.php
@@ -583,6 +583,7 @@ function cfct_choose_general_template_default($dir, $files) {
function cfct_choose_single_template($files = array(), $filter = '*', $dir = '') {
// must be called within the_loop - cfct_choose_general_template_single() approximates a loop for this reason.
$exec_order = array(
+ 'sticky',
'author',
'meta',
'format',
@@ -632,6 +633,26 @@ function cfct_choose_single_template_type($dir, $files, $filter) {
}
/**
+ * Chooses which template to display for the single context based on "sticky" status
+ *
+ * @param string $dir Directory to use for selecting the template file
+ * @param array $files A list of files to search through to find the correct template
+ * @param string $filter Used in filtering the filename
+ * @return mixed Path to the file, false if no file exists
+ *
+**/
+function cfct_choose_single_template_sticky($dir, $files, $filter) {
+ $sticky_files = cfct_sticky_templates($dir, $files, $filter);
+ if (count($sticky_files) && is_sticky()) {
+ $file = cfct_filename_filter('sticky.php', $filter);
+ if (in_array($file, $sticky_files)) {
+ return $file;
+ }
+ }
+ return false;
+}
+
+/**
* Chooses which template to display for the single context based on author login
*
* @param string $dir Directory to use for selecting the template file
@@ -1218,6 +1239,23 @@ function cfct_author_templates($dir, $files = null, $filter = '*') {
}
/**
+ * Is there a sticky template?
+ *
+ * @param string $dir Directory to search through for files if none are given
+ * @param array $files A list of files to search through
+ * @return array list of files that match the author template structure
+ *
+**/
+function cfct_sticky_templates($dir, $files = null, $filter = '*') {
+ if (is_null($files)) {
+ $files = cfct_files(CFCT_PATH.$dir);
+ }
+ $prefix = str_replace('*', '', $filter).'sticky';
+ $matches = cfct_filter_files($files, $prefix);
+ return apply_filters('cfct_sticky_templates', $matches);
+}
+
+/**
* Get a list of files that match the custom post type template structure
*
* @param string $dir Directory to search through for files if none are given
Please sign in to comment.
Something went wrong with that request. Please try again.