Ejemplo n.º 1
0
/**
 * Removes a theme from the list of sticky themes.
 *
 * @since  1.0.0
 * @access public
 * @param  int    $theme_id
 * @return bool
 */
function thds_remove_sticky_theme($theme_id)
{
    $theme_id = thds_get_theme_id($theme_id);
    if (thds_is_theme_sticky($theme_id)) {
        $stickies = thds_get_sticky_themes();
        $key = array_search($theme_id, $stickies);
        if (isset($stickies[$key])) {
            unset($stickies[$key]);
            return update_option('thds_sticky_themes', array_unique($stickies));
        }
    }
    return false;
}
Ejemplo n.º 2
0
/**
 * Returns the theme rating count.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $theme_id
 * @return int
 */
function thds_get_theme_rating_count($theme_id = 0)
{
    $theme_id = thds_get_theme_id($theme_id);
    return apply_filters('thds_get_theme_rating_count', absint(thds_get_theme_meta($theme_id, 'rating_count')), $theme_id);
}
Ejemplo n.º 3
0
/**
 * Returns a property from the WordPress.org theme object.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $theme_id
 * @param  string  $property
 * @return mixed
 */
function thds_get_wporg_theme_property($theme_id = 0, $property)
{
    $theme_id = thds_get_theme_id($theme_id);
    $theme_object = thds_get_wporg_theme($theme_id);
    $data = isset($theme_object->{$property}) ? $theme_object->{$property} : '';
    return apply_filters("thds_get_wporg_theme_{$property}", $data, $theme_id);
}
Ejemplo n.º 4
0
 /**
  * Callback function for handling post status changes.
  *
  * @since  1.0.0
  * @access public
  * @return void
  */
 public function handler()
 {
     // Checks if the sticky toggle link was clicked.
     if (isset($_GET['action']) && 'thds_toggle_sticky' === $_GET['action'] && isset($_GET['theme_id'])) {
         $theme_id = absint(thds_get_theme_id($_GET['theme_id']));
         // Verify the nonce.
         check_admin_referer("thds_toggle_sticky_{$theme_id}");
         if (thds_is_theme_sticky($theme_id)) {
             thds_remove_sticky_theme($theme_id);
         } else {
             thds_add_sticky_theme($theme_id);
         }
         // Redirect to correct admin page.
         $redirect = add_query_arg(array('updated' => 1), remove_query_arg(array('action', 'theme_id', '_wpnonce')));
         wp_safe_redirect(esc_url_raw($redirect));
         // Always exit for good measure.
         exit;
     }
     return;
 }