__( 'Main Navigation', 'Destro' )
) );
// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );
add_image_size( 'Destrothumb', 450, 300, true );
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
}
add_action( 'after_setup_theme', 'Destro_setup' );
/*
* Loads the Options Panel
*/
if ( !function_exists( 'optionsframework_init' ) ) {
/* Set the file path based on whether we're in a child theme or parent theme */
define('OPTIONS_FRAMEWORK_URL', get_template_directory() . '/admin/');
define('OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/admin/');
require_once (OPTIONS_FRAMEWORK_URL . 'options-framework.php');
}
/*
* This is an example of how to add custom scripts to the options panel.
* This example shows/hides an option when a checkbox is clicked.
*/
add_action('optionsframework_custom_scripts', 'optionsframework_custom_scripts');
function optionsframework_custom_scripts() { ?>
get_queried_object();
if ( isset( $page_obj->ID ) && $page_obj->ID >= 0 )
return $page_obj->ID;
return -1;
}
/**
* Get custom field of the current page
* $type = string|int
*/
function Destro_get_custom_field($filedname, $id = NULL, $single=true)
{
global $post;
if($id==NULL)
$id = get_the_ID();
if($id==NULL)
$id = Destro_get_page_id();
$value = get_post_meta($id, $filedname, $single);
if($single)
return stripslashes($value);
else
return $value;
}
/**
* Get Limited String
* $output = string
* $max_char = int
*/
function Destro_get_limited_string($output, $max_char=100, $end='...')
{
$output = str_replace(']]>', ']]>', $output);
$output = strip_tags($output);
$output = strip_shortcodes($output);
if ((strlen($output)>$max_char) && ($espacio = strpos($output, " ", $max_char )))
{
$output = substr($output, 0, $espacio).$end;
return $output;
}
else
{
return $output;
}
}
/**
* Tests if any of a post's assigned categories are descendants of target categories
*
* @param mixed $cats The target categories. Integer ID or array of integer IDs
* @param mixed $_post The post
* @return bool True if at least 1 of the post's categories is a descendant of any of the target categories
* @see get_term_by() You can get a category by name or slug, then pass ID to this function
* @uses get_term_children() Gets descendants of target category
* @uses in_category() Tests against descendant categories
* @version 2.7
*/
function Destro_post_is_in_descendant_category( $cats, $_post = null )
{
foreach ( (array) $cats as $cat ) {
// get_term_children() accepts integer ID only
$descendants = get_term_children( (int) $cat, 'category');
if ( $descendants && in_category( $descendants, $_post ) )
return true;
}
return false;
}
/**
* Twitter's Blogger.js output for Twitter widgets
* $unique_id = string
* $username = string
* limit = int
*/
function Destro_twitter_script($unique_id,$username,$limit) {
?>
', $image );
}
/**
* Update the widget settings.
*/
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* No need to strip tags for sex and show_sex. */
$instance['image'] = $new_instance['image'];
$instance['url'] = $new_instance['url'];
return $instance;
}
/**
* Displays the widget settings controls on the widget panel.
* Make use of the get_field_id() and get_field_name() function
* when creating your form elements. This handles the confusing stuff.
*/
function form( $instance ) {
/* Set up some default widget settings. */
$defaults = array( 'image' => __('', 'Destro'), 'url' => __('', 'Destro') );
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
'example', 'description' => __('An example widget that displays ads in sidebar.', 'Destro') );
/* Widget control settings. */
$control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => '125x125' );
/* Create the widget. */
$this->WP_Widget( '125x125', __('125x125 Ads', 'Destro'), $widget_ops, $control_ops );
}
/**
* How to display the widget on the screen.
*/
function widget( $args, $instance ) {
extract( $args );
/* Our variables from the widget settings. */
$image = $instance['image'];
$url= $instance['url'];
if ( $url )
printf( '
', $image );
}
/**
* Update the widget settings.
*/
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* No need to strip tags for sex and show_sex. */
$instance['image'] = $new_instance['image'];
$instance['url'] = $new_instance['url'];
return $instance;
}
/**
* Displays the widget settings controls on the widget panel.
* Make use of the get_field_id() and get_field_name() function
* when creating your form elements. This handles the confusing stuff.
*/
function form( $instance ) {
/* Set up some default widget settings. */
$defaults = array( 'image' => __('', 'Destro'), 'url' => __('', 'Destro') );
$instance = wp_parse_args( (array) $instance, $defaults ); ?>