args = $args;
}
public function __construct() {
}
public static function factory() {
return new cwp;
}
/**
*
*/
public static function logo($_name = null) {
$name = 'logo.png';
if (isset($_name))
$name = $_name;
$logo_url = get_template_directory_uri() . '/images/basejump.png';
if (file_exists(get_stylesheet_directory() . "/images/{$name}"))
$logo_url = get_stylesheet_directory_uri() . "/images/{$name}";
else if (file_exists(get_template_directory() . "/images/{$name}.png"))
$logo_url = get_template_directory_uri() . "/images/{$name}";
return $logo_url;
}
/**
* *************************************************************************
* file functions
* *************************************************************************
*/
/**
* Locates the file url
* @param type $filename
* @return string
*/
public static function locate_file_url($filename) {
//$path = '/tpl/' . $dir . '/' . $file;
$located = FALSE;
if (file_exists(get_stylesheet_directory() . '/' . $filename)):
$file = get_stylesheet_directory_uri() . '/' . $filename;
return $located = true;
elseif (file_exists(get_template_directory() . '/' . $filename)):
$file = get_template_directory_uri() . '/' . $filename;
return $located = true;
elseif (file_exists(get_stylesheet_directory() . $filename)):
$file = get_stylesheet_directory_uri() . '/' . $filename;
return $located = true;
elseif (file_exists(get_template_directory() . '/' . $filename)):
$file = get_template_directory_uri() . '/' . $filename;
return $located = true;
elseif (file_exists(get_stylesheet_directory() . '/' . $filename)):
$file = get_stylesheet_directory_uri() . '/' . $filename;
return $located = true;
elseif (file_exists(get_template_directory() . '/' . $filename)):
$file = get_template_directory_uri() . '/' . $filename;
return $located = true;
elseif (file_exists(STYLESHEETPATH . '/' . $filename)):
$file = get_stylesheet_directory_uri() . '/' . $filename;
return $located = true;
elseif (file_exists(TEMPLATEPATH . '/' . $filename)):
$file = get_template_directory_uri() . '/' . $filename;
return $located = true;
elseif (file_exists(CWP_URL . '/' . $filename)):
$file = CWP_URL . '/' . $filename;
return $file;
endif;
if (!$located):
return false;
else :
return $file;
endif;
}
/**
* Locate core-wp file template/modules/** , template/tpl/** , core-wp/modules/**
* @param type $filepath directory/filename.ext / filenamt.ext
* @return string
*/
public static function locate_file_path($filepath = null) {
//$file = PLUGINDIR . '/core-wp/' . $filepath;
$located = false;
if (file_exists(STYLESHEETPATH . $filepath)):
$file = STYLESHEETPATH . $filepath;
$located = true;
elseif (file_exists(TEMPLATEPATH . $filepath)):
$file = TEMPLATEPATH . $filepath;
$located = true;
elseif (file_exists(STYLESHEETPATH . $filepath)):
$file = STYLESHEETPATH . $filepath;
$located = true;
elseif (file_exists(TEMPLATEPATH . $filepath)):
$file = TEMPLATEPATH . '/' . $filepath;
$located = true;
elseif (file_exists(STYLESHEETPATH . '/' . $filepath)):
$file = STYLESHEETPATH . '/' . $filepath;
$located = true;
elseif (file_exists(TEMPLATEPATH . '/' . $filepath)):
$file = TEMPLATEPATH . '/' . $filepath;
$located = true;
elseif (file_exists(CM_PATH . '/' . $filepath)):
$file = CWP_PATH . '/' . $filepath;
$located = true;
endif;
if (!$located):
return false;
else :
return $file;
endif;
}
/**
* Locates a resource in the library file
*
* @param string $filename
* @param string $dir default- css
* @return string
*/
public static function locate_in_library($filename = null, $dir = 'css') {
$file = false;
if (isset($filename)):
$filepath = 'library/' . $dir . '/' . $filename;
if (file_exists(get_stylesheet_directory() . '/' . $filepath)):
$file = get_stylesheet_directory_uri() . '/' . $filepath;
elseif (file_exists(get_template_directory() . '/' . $filepath)):
$file = get_template_directory_uri() . '/' . $filepath;
elseif (CWP_PATH . '/' . $filepath):
$file = CWP_URL . '/' . $filepath;
endif;
return $file;
endif;
}
public static function css($name = 'style', $module = null) {
$path = $name . '.css';
if (isset($module))
$path = $module . '/css/' . $path;
$css = cwp::locate_file_url($path);
return $css;
}
public static function config($name = 'config', $module = null) {
$path = $name . '.php';
if (isset($module))
$path = $module . '/' . $path;
return $path;
}
public static function jquery() {
add_action('wp_enqueue_scripts', array('cwp', 'replace_jquery'));
}
public function replace_jquery() {
$url = 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
$version = '1.6.1';
// comment out the next two lines to load the local copy of jQuery
wp_deregister_script('jquery');
wp_register_script('jquery', $url, false, $version);
wp_enqueue_script('jquery');
}
public static function inuit_css($style = 'inuit') {
$path = CM_URL . '/inuit/css/';
$css = $path . 'inuit.css';
wp_enqueue_style('inuit', $css);
$grid = $path . 'grid.inuit.css';
wp_enqueue_style('grid-inuit', $grid, array('inuit'));
$dropdown = $path . 'dropdown.inuit.css';
wp_enqueue_style('dropdown-inuit', $dropdown, array('inuit'));
}
/**
* *************************************************************************
* MODULES
* *************************************************************************
*/
public static function get_module($template = 'index', $module = 'default', $data = array()) {
$mod = new core_tpl();
$mod->modules($template, $module, $data);
}
/**
*
* @global type $posts
* @global type $post
* @global type $wp_did_header
* @global type $wp_did_template_redirect
* @global type $wp_query
* @global type $wp_rewrite
* @global type $wpdb
* @global type $wp_version
* @global type $wp
* @global type $id
* @global type $comment
* @global type $user_ID
* @param string $template
* @param type $module
* @param type $data
* @param type $require_once
*/
public static function modules($template = 'loop', $module = 'default', $data = array(), $require_once = false) {
global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
if (is_array($data) AND !empty($data))
extract($data);
$template = $template . '.php';
//$file = PLUGINDIR . '/core-wp/modules/' . $module . '/tpl/' . $template;
$file = CM_PATH . '/' . $module . '/tpl/' . $template;
if (file_exists(STYLESHEETPATH . '/tpl/' . $template)) {
$file = STYLESHEETPATH . '/tpl/' . $template;
} elseif (file_exists(STYLESHEETPATH . '/' . $template)) {
$file = STYLESHEETPATH . '/' . $template;
} elseif (file_exists(TEMPLATEPATH . '/tpl/' . $template)) {
$file = TEMPLATEPATH . '/tpl/' . $template;
} elseif (file_exists(TEMPLATEPATH . '/' . $template)) {
$file = TEMPLATEPATH . '/' . $template;
}
if (file_exists($file))
if ($require_once):
require_once $file;
else:
require $file;
endif;
else
echo "MODULE NOT FOUND";
}
public static function css_reset($normalize = false) {
if ($normalize):
wp_enqueue_style('normalize', CM_URL . '/css/normalize.css');
else :
wp_enqueue_style('reset', CM_URL . '/css/reset.css');
endif;
}
public static function baseline() {
//wp_enqueue_style('baseline-type', CM_URL .'/baseline/baseline.type.css');
//wp_enqueue_style('baseline-form', CM_URL .'/baseline/baseline.form.css');
}
public static function css_960() {
?>
ID;
if (isset($ID))
$id = $ID;
$img_id = get_post_thumbnail_id($id);
$imgs = wp_get_attachment_image_src($img_id, $size);
if ($imgs):
$src = '';
else :
$src = '
';
endif;
echo $src;
}
/**
* *************************************************************************
* Themes / TPL
* *************************************************************************
*/
/**
*
* @param type $slug default content
*/
public static function get_tpl($slug = 'default') {
$tpl = new core_tpl($slug);
$template = $tpl->tpl($slug);
load_template($template, false);
}
public static function get_tpl_part($slug, $name = null) {
//core_tpl::locate_tpl($template_names, $slug);
}
public static function get_tpl_content($name = null) {
//core_tpl::locate_tpl($template_names, $slug);
$template = core_tpl::get_tpl_part('content', $name);
//echo 'pate--'.$template;
}
public static function get_tpl_design($name = null) {
//core_tpl::locate_tpl($template_names, $slug);
$template = core_tpl::get_tpl_part('design', $name);
//echo 'pate--'.$template;
}
public static function get_tpl_code($name = null) {
//core_tpl::locate_tpl($template_names, $slug);
$template = core_tpl::get_tpl_part('code', $name);
//echo 'pate--'.$template;
}
public static function get_tpl_data($name = null) {
//core_tpl::locate_tpl($template_names, $slug);
$template = core_tpl::get_tpl_part('data', $name);
//echo 'pate--'.$template;
}
/**
* mover to the csf_functions file theme directory
*/
public static function theme_images() {
add_image_size('slideshow-980', 980, 420, true);
add_image_size('slideshow-1200', 1180, 550, true);
add_image_size('slideshow-1560', 1540, 550, true);
add_image_size('slideshow-720', 600, 550, true);
add_image_size('grid-thumbnail', 370, 270, true);
add_image_size('icon-60', 60, 60, true);
add_image_size('icon-100', 100, 100, true);
add_image_size('icon-40', 40, 40, true);
}
public static function remove_update_notification() {
global $user_login;
get_currentuserinfo();
if ($user_login !== "admin") { // change admin to the username that gets the updates
add_action('init', create_function('$a', "remove_action( 'init', 'wp_version_check' );"), 2);
add_filter('pre_option_update_core', create_function('$a', "return null;"));
}
}
public static function remove_head_meta() {
// remove junk from head
if (!is_admin()):
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
//remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
endif;
}
public static function shortcodes_in_widgets() {
// shortcode in widgets
if (!is_admin()) {
add_filter('widget_text', 'do_shortcode', 11);
}
}
public static function theme_setup() {
self::jquery();
self::shortcodes_in_widgets();
self::remove_head_meta();
self::remove_update_notification();
self::theme_images();
add_theme_support('post-thumbnails');
add_theme_support('automatic-feed-links');
core_functions::favicon();
core_functions::no_smiley_face();
core_functions::all_post_formats();
}
/**
* Deprecated use register sidebar
* @param type $name
* @param type $widget_id
* @param type $description
* @param type $id
* @param type $div
* @param type $title
*/
public static function add_widget($name, $widget_id, $description = "", $id = 'widgets', $div = "aside", $title = 'h3') {
//$widget_id = preg_replace(" ", "-", $name);
register_sidebar(array(
'name' => ucfirst($name),
'id' => $widget_id,
'description' => __($description),
'before_widget' => '<' . $div . ' id="%1$s" class="widget %2$s">',
'after_widget' => "{$div}>",
'before_title' => '<' . $title . ' class="widget-title">',
'after_title' => '' . $title . '>',
));
}
/**
*
* @param type $name
* @param type $widget_id
* @param type $description
* @param type $id
* @param type $div
* @param type $title
*
*
* //example
* cwp::add_widget('Top Sidebar', 'top-sidebar', 'Top sidebar widget');
*
*/
public static function register_sidebar($name, $widget_id, $description = "", $div = "div", $title = 'h3') {
//$widget_id = preg_replace(" ", "-", $name);
register_sidebar(array(
'name' => ucfirst($name),
'id' => $widget_id,
'description' => $description,
'before_widget' => '<' . $div . ' id="%1$s" class="widget %2$s">',
'after_widget' => "{$div}>",
'before_title' => '<' . $title . ' class="widget-title">',
'after_title' => '' . $title . '>',
));
}
/**
*
* @param type $name
* @param type $widget_id
* @param type $description
* @param type $id
* @param type $div
* @param type $title
*
*
* //example
* cwp::add_widget('Top Sidebar', 'top-sidebar', 'Top sidebar widget');
*
*/
public static function register_sidebar_footer($name, $widget_id, $description = "", $class = "span3", $id = 'widgets', $title = 'h3') {
//$widget_id = preg_replace(" ", "-", $name);
register_sidebar(array(
'name' => ucfirst($name),
'id' => $widget_id,
'description' => $description,
'before_widget' => '
* //example
* cwp::add_widget('Top Sidebar', 'top-sidebar', 'Top sidebar widget');
*
*/
public static function register_sidebar_grid($name, $widget_id, $description = "", $class = "span4", $id = 'widgets', $title = 'h3') {
//$widget_id = preg_replace(" ", "-", $name);
register_sidebar(array(
'name' => ucfirst($name),
'id' => $widget_id,
'description' => $description,
'before_widget' => '