/**
  * Process a file, executing Compass executable.
  *
  * Execute the Compass executable, overriding the no-op function inside
  * WordlessPreprocessor.
  */
 protected function process_file($file_path, $result_path, $temp_path)
 {
     $this->validate_executable_or_die($this->preference("compass.compass_path"));
     // On cache miss, we build the file from scratch
     $pb = new ProcessBuilder(array($this->preference("compass.compass_path"), 'compile', $temp_path));
     $config = array("http_path" => Wordless::theme_url(), "images_dir" => "assets/images", "css_path" => $temp_path, "relative_assets" => false, "output_style" => ":" . $this->preference("compass.output_style"), "environment" => ":production", "sass_path" => dirname($file_path));
     $ruby_config = array();
     foreach ($config as $name => $value) {
         if (strpos($value, ":") === 0) {
             $ruby_config[] = sprintf('%s = %s', $name, $value);
         } else {
             if (is_bool($value)) {
                 $ruby_config[] = sprintf('%s = %s', $name, $value ? "true" : "false");
             } else {
                 $ruby_config[] = sprintf('%s = "%s"', $name, addcslashes($value, '\\'));
             }
         }
     }
     $config_path = tempnam($temp_path, 'compass_config');
     file_put_contents($config_path, implode("\n", $ruby_config) . "\n");
     $pb->add("--config")->add($config_path);
     $output = $temp_path . "/" . basename($file_path, pathinfo($file_path, PATHINFO_EXTENSION)) . 'css';
     $proc = $pb->getProcess();
     $code = $proc->run();
     if (0 < $code) {
         unlink($config_path);
         $this->die_with_error($proc->getErrorOutput());
     }
     unlink($config_path);
     return file_get_contents($output);
 }
Beispiel #2
0
 public static function start()
 {
     global $argv, $theme_name;
     parent::initialize();
     require_once Wordless::join_paths(self::$plugin_dir, "wordless", "theme_builder.php");
     $theme_name = $argv[1] ? $argv[1] : 'wordless';
     $permissions = substr(sprintf('%o', fileperms(self::$plugin_dir)), -4);
     $builder = new WordlessThemeBuilder($theme_name, $theme_name, intval($permissions, 8));
     $builder->build();
 }
Beispiel #3
0
 public static function check_roles()
 {
     if (current_user_can('edit_theme_options')) {
         if (!Wordless::theme_is_wordless_compatible()) {
             // Display a notice if options.php isn't present in the theme
             add_action('admin_notices', array('WordlessAdmin', 'add_notice'));
         }
         // If the user can edit theme options, let the fun begin!
         add_action('admin_menu', array('WordlessAdmin', 'add_page'));
     }
 }
 /**
  * Overrides WordlessPreprocessor::asset_hash()
  * @attention This is raw code. Right now all we do is find all the *.{sass,scss} files, concat
  * them togheter and generate an hash. We should find exacty the sass files required by
  * $file_path asset file.
  */
 protected function asset_hash($file_path)
 {
     $hash = array(parent::asset_hash($file_path));
     $base_path = dirname($file_path);
     $files = Wordless::recursive_glob(dirname($base_path), '*.{sass,scss}', GLOB_BRACE);
     sort($files);
     $hash_seed = array();
     foreach ($files as $file) {
         $hash_seed[] = $file . date("%U", filemtime($file));
     }
     return md5(join($hash_seed));
 }
 /**
  * Overrides WordlessPreprocessor::asset_hash()
  * @attention This is raw code. Right now all we do is find all the *.{sass,scss} files, concat
  * them togheter and generate an hash. We should find exacty the sass files required by
  * $file_path asset file.
  */
 protected function asset_hash($file_path)
 {
     $hash = array(parent::asset_hash($file_path));
     $base_path = dirname($file_path);
     $files = Wordless::recursive_glob(dirname($base_path), '*.{sass,scss}', GLOB_BRACE);
     sort($files);
     $hash_seed = array();
     foreach ($files as $file) {
         $hash_seed[] = $file . date("%U", filemtime($file));
     }
     // Concat original file onto hash seed for uniqueness so each file is unique
     $hash_seed[] = $file_path;
     return md5(join($hash_seed));
 }
Beispiel #6
0
 public static function add_notice()
 {
     // Get a list of missing directories
     $dirs_missing = Wordless::theme_is_wordless_compatible(true);
     echo '<div class="error"><p>';
     echo sprintf(__('Your current theme does not seem to be a Wordless-compatible theme! <a href="%2$s" target="_blank">%1$s</a> (or <a href="%4$s" target="_blank">%3$s</a>)', "wl"), __('Create a new Wordless theme', "wl"), admin_url('admin.php?page=wordless'), __('learn more about Wordless', "wl"), 'https://github.com/welaika/wordless#readme');
     echo "</p>";
     echo "<p><strong>Error found:</strong></p>";
     echo "<ul>";
     foreach ($dirs_missing as $dir) {
         echo "<li>Missing Directory: " . $dir . "</li>";
     }
     echo "</ul>";
     echo "</div>";
 }
 /**
  * Overrides WordlessPreprocessor::process_file()
  */
 protected function process_file($file_path, $result_path, $temp_path)
 {
     $this->validate_executable_or_die($this->preference("sprockets.ruby_path"));
     // On cache miss, we build the JS file from scratch
     $pb = new ProcessBuilder(array($this->preference("sprockets.ruby_path"), Wordless::join_paths(dirname(__FILE__), "sprockets_preprocessor.rb")));
     // Fix for MAMP environments, see http://goo.gl/S5KFe for details
     $pb->setEnv("DYLD_LIBRARY_PATH", "");
     $pb->add(Wordless::theme_static_javascripts_path());
     $pb->add(Wordless::theme_javascripts_path());
     $pb->add($file_path);
     $proc = $pb->getProcess();
     $code = $proc->run();
     if ($code != 0) {
         $this->die_with_error($proc->getErrorOutput());
     }
     return $proc->getOutput();
 }
 function render_template($name)
 {
     $tmp_dir = Wordless::theme_temp_path();
     $template_path = Wordless::join_paths(Wordless::theme_views_path(), "{$name}.haml");
     if (!is_file($template_path)) {
         render_error("Template missing", "<strong>Ouch!!</strong> It seems that <code>{$template_path}</code> doesn't exist!");
     }
     if (!file_exists($tmp_dir)) {
         mkdir($tmp_dir, 0760);
     }
     if (!is_writable($tmp_dir)) {
         chmod($tmp_dir, 0760);
     }
     if (is_writable($tmp_dir)) {
         $haml = new HamlParser(array('style' => 'expanded', 'ugly' => false));
         include $haml->parse($template_path, $tmp_dir);
     } else {
         render_error("Temp dir not writable", "<strong>Ouch!!</strong> It seems that the <code>{$tmp_dir}</code> directory is not writable by the server! Go fix it!");
     }
 }
Beispiel #9
0
 public static function start()
 {
     parent::initialize();
     // Determine theme name
     foreach (scandir(self::$current_dir . '/wp-content/themes') as $theme_dir) {
         if (in_array($theme_dir, array('.', '..', 'index.php')) && !is_dir($theme_dir)) {
             continue;
         }
         $previous_theme_name = WordlessBridge::$theme_name;
         WordlessBridge::$theme_name = $theme_dir;
         if (Wordless::theme_is_wordless_compatible()) {
             if (basename(self::$current_dir) == $theme_dir) {
                 // A theme with the same name as the site is Wordless-compatible, this is probably the one we want
                 break;
             }
         } else {
             WordlessBridge::$theme_name = $previous_theme_name;
         }
     }
     require get_template_directory() . '/config/initializers/wordless_preferences.php';
     Wordless::register_preprocessors();
     Wordless::compile_assets();
 }
Beispiel #10
0
 /**
  * Renders a template and its contained plartials. Accepts
  * a list of locals variables which will be available inside
  * the code of the template
  *
  * @param  string $name   The template filenames (those not starting
  *                        with an underscore by convention)
  *
  * @param  array  $locals An associative array. Keys will be variables'
  *                        names and values will be variable values inside
  *                        the template
  *
  * @see php.bet/extract
  *
  */
 function render_template($name, $locals = array())
 {
     $valid_filenames = array("{$name}.html.haml", "{$name}.haml", "{$name}.html.php", "{$name}.php");
     foreach ($valid_filenames as $filename) {
         $path = Wordless::join_paths(Wordless::theme_views_path(), $filename);
         if (is_file($path)) {
             $template_path = $path;
             $arr = explode('.', $path);
             $format = array_pop($arr);
             break;
         }
     }
     if (!isset($template_path)) {
         render_error("Template missing", "<strong>Ouch!!</strong> It seems that <code>{$name}.html.haml</code> or <code>{$name}.html.php</code> doesn't exist!");
     }
     extract($locals);
     switch ($format) {
         case 'haml':
             $tmp_dir = Wordless::theme_temp_path();
             if (!file_exists($tmp_dir)) {
                 mkdir($tmp_dir, 0760);
             }
             if (!is_writable($tmp_dir)) {
                 chmod($tmp_dir, 0760);
             }
             if (is_writable($tmp_dir)) {
                 $haml = new HamlParser(array('style' => 'expanded', 'ugly' => false));
                 include $haml->parse($template_path, $tmp_dir);
             } else {
                 render_error("Temp dir not writable", "<strong>Ouch!!</strong> It seems that the <code>{$tmp_dir}</code> directory is not writable by the server! Go fix it!");
             }
             break;
         case 'php':
             include $template_path;
             break;
     }
 }
 /**
  * Overrides WordlessPreprocessor::process_file()
  */
 protected function process_file($file_path, $temp_path)
 {
     $this->validate_executable_or_throw($this->preference("js.ruby_path"));
     // On cache miss, we build the JS file from scratch
     $pb = new ProcessBuilder(array($this->preference("js.ruby_path"), Wordless::join_paths(dirname(__FILE__), "sprockets_preprocessor.rb"), "compile"));
     // Fix for MAMP environments, see http://goo.gl/S5KFe for details
     $pb->setEnv("DYLD_LIBRARY_PATH", "");
     $pb->add($file_path);
     $pb->add("--paths");
     $pb->add(Wordless::theme_static_javascripts_path());
     $pb->add(Wordless::theme_javascripts_path());
     if ($this->preference("js.yui_compress")) {
         $pb->add("--compress");
     }
     if ($this->preference("js.yui_munge")) {
         $pb->add("--munge");
     }
     $proc = $pb->getProcess();
     $code = $proc->run();
     if ($code != 0) {
         throw new WordlessCompileException("Failed to run the following command: " . $proc->getCommandLine(), $proc->getErrorOutput());
     }
     return $proc->getOutput();
 }
Beispiel #12
0
<?php

class UrlHelper
{
    function asset_url($path)
    {
        return parse_url(get_bloginfo('stylesheet_directory'), PHP_URL_PATH) . "/assets/{$path}";
    }
    function image_url($path)
    {
        return asset_url("images/{$path}");
    }
    function stylesheet_url($path)
    {
        return asset_url("stylesheets/{$path}");
    }
    function javascript_url($path)
    {
        return asset_url("javascripts/{$path}");
    }
}
Wordless::register_helper("UrlHelper");
<?php

/*
 * Configure Wordless preferences here.
 */
Wordless::set_preference("assets.preprocessors", array("SprocketsPreprocessor", "CompassPreprocessor"));
// Wordless::set_preference("assets.cache_enabled", true);
// Wordless::set_preference("assets.version", get_theme_version());
// Wordless::set_preference("css.compass_path",     "/usr/bin/compass");
// Wordless::set_preference("css.output_style",     "compressed");
// Wordless::set_preference("css.require_libs",     array());
// Wordless::set_preference("css.lessc_path",       "/usr/bin/lessc");
// Wordless::set_preference("css.compress",         false);
// Wordless::set_preference("js.ruby_path",         "/usr/bin/ruby");
// Wordless::set_preference("js.yui_compress",      false);
// Wordless::set_preference("js.yui_munge",         false);
Beispiel #14
0
        if (!is_array($name)) {
            $name = array("singular" => $name, "plural" => pluralize($name));
        }
        $uc_plural = __(ucwords(preg_replace("/_/", " ", $name["plural"])));
        $uc_singular = __(ucwords(preg_replace("/_/", " ", $name["singular"])));
        $labels = array('name' => $uc_plural, 'singular_name' => $uc_singular, 'add_new_item' => sprintf(__("Add new %s", "we"), $uc_singular), 'edit_item' => sprintf(__("Edit %s", "we"), $uc_singular), 'new_item' => sprintf(__("New %s", "we"), $uc_singular), 'view_item' => sprintf(__("View %s", "we"), $uc_singular), 'search_items' => sprintf(__("Search %s", "we"), $uc_plural), 'not_found' => sprintf(__("No %s found.", "we"), $uc_plural), 'not_found_in_trash' => sprintf(__("No %s found in Trash", "we"), $uc_plural), 'parent_item_colon' => ',', 'menu_name' => $uc_plural);
        register_post_type($name["singular"], array('labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'has_archive' => true, 'rewrite' => array('slug' => $name["plural"]), 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => $supports));
    }
    /**
     * Create a new taxonomy.
     * 
     * @param string $name
     *   The name of the taxonomy.
     * @param $post_types
     * @param boolean $hierarchical (optional)
     * 
     * @ingroup helperfunc
     */
    function new_taxonomy($name, $post_types, $hierarchical = true)
    {
        if (!is_array($name)) {
            $name = array("singular" => $name, "plural" => pluralize($name));
        }
        $uc_plural = ucwords(preg_replace("/_/", " ", $name["plural"]));
        $uc_singular = ucwords(preg_replace("/_/", " ", $name["singular"]));
        $labels = array("name" => $uc_singular, "singular_name" => $uc_singular, "search_items" => sprintf(__("Search %s", "we"), $uc_plural), "all_items" => sprintf(__("All %s", "we"), $uc_plural), "parent_item" => sprintf(__("Parent %s", "we"), $uc_singular), "parent_item_colon" => sprintf(__("Parent %s:", "we"), $uc_singular), "edit_item" => sprintf(__("Edit %s", "we"), $uc_singular), "update_item" => sprintf(__("Update %s", "we"), $uc_singular), "add_new_item" => sprintf(__("Add new %s", "we"), $uc_singular), "new_item_name" => sprintf(__("New %n Name", "we"), $uc_singular), "menu_name" => $uc_plural);
        register_taxonomy($name["singular"], $post_types, array('hierarchical' => $hierarchical, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $name["plural"])));
    }
}
Wordless::register_helper("ModelHelper");
Beispiel #15
0
 /**
  * Return the theme version, based on prederence set in Wordless config file.
  *
  * @return string
  *   The assets version string
  *
  * @ingroup helperfunc
  */
 protected function get_asset_version_string()
 {
     return Wordless::preference('assets.version', NULL);
 }
Beispiel #16
0
                $new_height = $height_orig * $ratio;
                $image_scaled = imagecreatetruecolor($new_width, $new_height);
                // scaling!
                imagecopyresampled($image_scaled, $image, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
                $image = $image_scaled;
                if ($new_width > $width || $new_height > $height) {
                    $to_crop = TRUE;
                }
            } else {
                $new_width = $width_orig;
                $new_height = $height_orig;
            }
            // we need to crop the image
            if ($to_crop) {
                $image_cropped = imagecreatetruecolor($width, $height);
                // find margins for images
                $margin_x = ($new_width - $width) / 2;
                $margin_y = ($new_height - $height) / 2;
                // cropping!
                imagecopy($image_cropped, $image, 0, 0, $margin_x, $margin_y, $width, $height);
                $image = $image_cropped;
            }
            // Save image
            imagejpeg($image, $img_filename, 95);
        }
        // Return image URL
        return get_bloginfo("template_url") . '/tmp/' . basename($img_filename);
    }
}
Wordless::register_helper("ImageHelper");
<?php

/*
* This is an auto-generated preferences file. If you want to configure Wordless preferences go to WordPress backend.
*/
Wordless::set_preference("assets.preprocessors", array(0 => 'SprocketsPreprocessor', 1 => 'CompassPreprocessor'));
Wordless::set_preference("assets.cache_enabled", true);
Wordless::set_preference("css.compass_path", "C:\\Ruby22\\bin\\compass.bat");
Wordless::set_preference("css.output_style", "compressed");
Wordless::set_preference("css.require_libs", array(0 => ''));
Wordless::set_preference("css.lessc_path", "");
Wordless::set_preference("css.compress", false);
Wordless::set_preference("js.ruby_path", "C:\\Ruby22\\bin\\ruby.exe");
Wordless::set_preference("js.yui_compress", false);
Wordless::set_preference("js.yui_munge", false);
 /**
  * Handy wrapper to retrieve a preference from the Wordless::preference()
  * method.
  *
  * If the preference is not set, the returned value will be the one specified
  * using the WordlessPreprocessor::set_preference_default_value() method.
  *
  * @see Wordless:preference()
  * @see Wordless:set_preference_default()
  */
 protected function preference($name)
 {
     $possible_names = array($name);
     if (isset($this->deprecated_preferences[$name])) {
         $possible_names = $this->deprecated_preferences[$name];
         array_unshift($possible_names, $name);
     }
     foreach ($possible_names as $possible_name) {
         $value = Wordless::preference($possible_name, NULL);
         if (isset($value)) {
             return $value;
         }
     }
     return $this->preferences_defaults[$name];
 }
<?php

/*
 * Configure Wordless preferences here.
 */
// Wordless::set_preference("compass.compass_path",     "/usr/bin/compass");
Wordless::set_preference("compass.compass_path", "/Users/nerdfiles/.rvm/bin/wordless_compass");
//Wordless::set_preference("sprockets.ruby_path",      "/usr/bin/ruby");
Wordless::set_preference("sprockets.ruby_path", "/Users/nerdfiles/.rvm/bin/wordless_ruby");
Wordless::set_preference("assets.cache_enabled", false);
Beispiel #20
0
 /**
  * Require one directory
  * @param string $path
  */
 public static function require_once_dir($path)
 {
     $list_files = glob(Wordless::join_paths($path, "*.php"));
     if (is_array($list_files)) {
         foreach ($list_files as $filename) {
             require_once $filename;
         }
     }
 }
Beispiel #21
0
    /**
     * Generate placeholder text.
     * 
     * Using the famous Lorem Ipsum base text, generate a dummy text based on 
     * specified options.
     * 
     * @param int $count
     *   The length in words of the dummy text.
     * @param array $options
     *   (optional) An array of options to manage text generation. Options 
     *   available are:
     *   - html: wheter to build HTML content or plain content. Default to false.
     *   - lorem: if the text must start with "Lorem ipsum..." or not.
     *     Default to true.
     * 
     * @return @e string 
     *   The generated dummy text.
     * 
     * @ingroup helperfunc
     */
    public function placeholder_text($count, $options = array())
    {
        $options = array_merge(array('html' => false, 'lorem' => true), $options);
        $generator = new LoremIpsumGenerator();
        $html_format = $options['html'] ? 'plain' : 'html';
        $start_with_lorem_ipsum = $options['lorem'];
        return ucfirst($generator->getContent($count, $html_format, $start_with_lorem_ipsum));
    }
}
Wordless::register_helper("FakerHelper");
Beispiel #22
0
    function titleize($text)
    {
        $words = explode(" ", $text);
        $capitalized_words = array();
        foreach ($words as $word) {
            $capitalized_words[] = capitalize($word);
        }
        return join(" ", $capitalized_words);
    }
    /**
     * Check if the string passed as parameter is a valid URL.
     * 
     * NO SANITAZE IS PERFORMED on the URL! URL like this:
     *   http://example.com/"><script>alert(document.cookie)</script>
     * DO PASS validation (syntactically are valid URLs).
     * 
     * @param string $url
     *   A URL to be validated.
     * 
     * @return bool
     *   Return TRUE if the URL is valid, FALSE otherwise.
     * 
     * @ingroup helperfunc
     */
    function is_valid_url($url)
    {
        return (bool) filter_var($url, FILTER_VALIDATE_URL);
    }
}
Wordless::register_helper("TextHelper");
Beispiel #23
0
     *   A valid HTML \<time /\> tag.
     *
     * @ingroup helperfunc
     *
     * @see TagHelper::content_tag()
     */
    function time_tag($date_or_time = NULL, $text = NULL, $attributes = array())
    {
        $date_or_time = $date_or_time ? date(DATE_W3C, $date_or_time) : date(DATE_W3C);
        $options = array("datetime" => $date_or_time);
        $text = $text ? $text : strftime("%F", $date_or_time);
        $options = array_merge($options, $attributes);
        return content_tag("time", $text, $options);
    }
    /**
     * Like distance_of_time_in_words() but with fixed value of $to_time.
     *
     * This functions is a shorthand for distance_of_time_in_words($from_time,
     * time(), $include_seconds).
     *
     * @ingroup helperfunc
     *
     * @see distance_of_time_in_words()
     */
    function time_ago_in_words($from_time, $include_seconds = false)
    {
        return distance_of_time_in_words($from_time, time(), $include_seconds);
    }
}
Wordless::register_helper("DateHelper");
Beispiel #24
0
     * The function use the whole theme path to get only the folder name of the
     * current theme.
     * 
     * @return string
     *   The folder name for the current theme.
     * 
     * @ingroup helperfunc
     */
    function get_theme_name()
    {
        $temp = explode("wp-content/themes/", get_bloginfo("template_url"));
        return $temp[1];
        // The second value will be the theme name
    }
    /**
     * Returns the absolute path to the current theme.
     * 
     * Path without trailing slash.
     * 
     * @return string
     *   The absolute path to the current theme.
     * 
     * @ingroup helperfunc
     */
    function get_theme_path()
    {
        return get_theme_root() . '/' . get_theme_name();
    }
}
Wordless::register_helper("ThemeHelper");
Beispiel #25
0
        $options = array_merge(self::$DEFAULT_CURRENCY_VALUES, $options);
        $precision = $this->array_delete($options, 'precision');
        $significant = $this->array_delete($options, 'significant');
        $strip_insignificant_zeros = $this->array_delete($options, 'strip_insignificant_zeros');
        if ($significant && $precision > 0) {
            if ($number == 0) {
                $digits = 1;
                $rounded_number = 0;
            } else {
                $digits = floor(log10(abs($number)) + 1);
                $rounded_number = (double) round($number / (double) pow(10, $digits - $precision)) * pow(10, $digits - $precision);
                $digits = floor(log10(abs($rounded_number)) + 1);
            }
            $precision -= $digits;
            $precision = $precision > 0 ? $precision : 0;
            // don't let precision be negative
        } else {
            $rounded_number = (double) round($number, $precision);
        }
        $formatted_number = number_with_delimiter(sprintf("%01.{$precision}f", $rounded_number), $options);
        if ($strip_insignificant_zeros) {
            $escaped_separator = preg_quote($options['separator']);
            $formatted_number = preg_replace("/({$escaped_separator})(\\d*[1-9])?0+\\z/", '\\1\\2', $formatted_number);
            return preg_replace("/{$escaped_separator}\\z/", '', $formatted_number);
        } else {
            return $formatted_number;
        }
    }
}
Wordless::register_helper("NumberHelper");
Beispiel #26
0
 public function build()
 {
     $source_path = Wordless::join_paths(dirname(__FILE__), "theme_builder", "vanilla_theme");
     $this->copy($source_path, $this->theme_dir);
 }
    function link_to($text = '', $link = NULL, $attributes = NULL)
    {
        if (!is_string($link)) {
            $link = "#";
        }
        $options = array("href" => $link);
        if (is_array($attributes)) {
            $options = array_merge($options, $attributes);
        }
        return $this->content_tag("a", $text, $options);
    }
    function content_type_meta_tag($content = NULL)
    {
        $content = $content ? $content : get_bloginfo('html_type') . '; ' . 'charset=' . get_bloginfo('charset');
        $attrs = array("http-equiv" => "Content-type", "content" => $content);
        return content_tag("meta", NULL, $attrs);
    }
    function title_tag($title = NULL, $attributes = array())
    {
        $title = $title ? $title : get_page_title();
        return content_tag("title", $title, $attributes);
    }
    function pingback_link_tag($url = NULL)
    {
        $url = $url ? $url : get_bloginfo('pingback_url');
        $attributes = array("href" => $url);
        return content_tag("link", NULL, $attributes);
    }
}
Wordless::register_helper("TagHelper");
Beispiel #28
0
<?php

/*
Plugin Name: Wordless
Plugin URI: https://github.com/welaika/wordless
Description: Wordless dramatically speeds up and enhances your custom themes creation, thanks to Sass, Compass, Haml and Coffeescript.
Version: 0.4
Author: weLaika
Author URI: http://welaika.com/
License: The MIT License
*/
require_once "wordless/wordless.php";
Wordless::initialize();
Beispiel #29
0
        }
        if (is_single() || is_page()) {
            $title = get_the_title();
        }
        if (is_search()) {
            $title = sprintf(__("Search: %s", "wl"), get_search_query());
        }
        if (is_date()) {
            if (is_month()) {
                $date = get_the_date("F Y");
            } else {
                if (is_year()) {
                    $date = get_the_date("Y");
                } else {
                    $date = get_the_date();
                }
            }
            $title = sprintf(__("Archives: %s", "wl"), $date);
        }
        if (is_front_page() || is_home()) {
            $title = get_bloginfo("description", "display");
        }
        if ($title != "") {
            return "{$prefix}{$separator}{$title}";
        } else {
            return $prefix;
        }
    }
}
Wordless::register_helper("QueryHelper");
        $metas = array();
        $groups = $connector["field_groups"];
        if (!$groups) {
            return array();
        }
        foreach ($groups as $group) {
            $metas[$group["name"]] = array();
            $fields = $group["fields"];
            foreach ($fields as $field) {
                if (sizeof($field["saved_values"]) == 1) {
                    $metas[$group["name"]][$field["name"]] = $field["saved_values"][0];
                } else {
                    $metas[$group["name"]][$field["name"]] = $field["saved_values"];
                }
            }
        }
        return $metas;
    }
    /**
     * @deprecated Dismissing support for simple field helper after adoption
     *             of Advanced Custom Field as default custom fileds creation
     *             plug-in
     */
    function simple_fields_meta($post, $group, $field)
    {
        $metas = simple_fields_metas($post);
        return $metas[$group][$field];
    }
}
Wordless::register_helper("SimpleFieldsHelper");