Exemplo n.º 1
0
function wpi_get_relative_date($timestamp)
{
    if (wpi_user_func_exists('time_since')) {
        $date = abs(strtotime($timestamp) - 60 * 120);
        return time_since($date) . ' ' . __('ago', WPI_META);
    } else {
        return $timestamp;
    }
}
Exemplo n.º 2
0
function wpi_current_template()
{
    $section = is_at();
    $callback = 'wpi_template_' . $section;
    if (!wpi_user_func_exists($callback)) {
        wpi_template_404();
    } else {
        $f = array();
        $f['wpi_authordata_display_name'] = 'wpi_author_display_name_filter';
        //$f['the_content'] 					= 'wpi_attachment_image_filters';
        if ($section == wpiSection::CATEGORY || $section == wpiSection::TAXONOMY || $section == wpiSection::ARCHIVE || $section == wpiSection::YEAR || $section == wpiSection::MONTH || $section == wpiSection::DAY) {
            $f['the_content'] = 'wpi_cat_content_filter';
        }
        if ($section == wpiSection::SEARCH) {
            $f['the_content'] = 'wpi_search_content_filter';
        }
        if ($section == wpiSection::SINGLE || $section == wpiSection::PAGE || $section == wpiSection::HOME) {
            $f['the_content'] = 'wpi_google_ads_targeting_filter';
        }
        wpi_foreach_hook_filter($f);
        call_user_func($callback);
        foreach ($f as $h => $c) {
            remove_filter($h, $c);
        }
        unset($f);
    }
}
Exemplo n.º 3
0
                    } elseif (preg_match($regex, $filename)) {
                        $list[] = $filename;
                    }
                }
            }
            unset($dir, $file);
            return $list;
        } catch (Exception $ex) {
            return false;
        }
    } else {
        // @todo fallback
        return;
    }
}
if (!wpi_user_func_exists('format_filesize')) {
    function format_filesize($rawSize)
    {
        if ($rawSize / 1099511627776 > 1) {
            return round($rawSize / 1099511627776, 1) . ' ' . __('TiB', WPI_META);
        } elseif ($rawSize / 1073741824 > 1) {
            return round($rawSize / 1073741824, 1) . ' ' . __('GiB', WPI_META);
        } elseif ($rawSize / 1048576 > 1) {
            return round($rawSize / 1048576, 1) . ' ' . __('MiB', WPI_META);
        } elseif ($rawSize / 1024 > 1) {
            return round($rawSize / 1024, 1) . ' ' . __('KiB', WPI_META);
        } elseif ($rawSize > 1) {
            return round($rawSize, 1) . ' ' . __('bytes', WPI_META);
        } else {
            return __('unknown', WPI_META);
        }
Exemplo n.º 4
0
function wpi_most_download_widget()
{
    if (!wpi_user_func_exists('get_most_downloaded')) {
        return false;
    }
    global $wp_query;
    // asume downloads is located at download page
    if (get_option('download_page_url') != self_uri()) {
        return;
    }
    $limit = 5;
    wpi_widget_start('Most downloads', 'most-downloads');
    $htm = get_most_downloaded($limit, 0, false);
    t('ul', $htm, array('class' => 'select-odd'));
    wpi_widget_end();
}
Exemplo n.º 5
0
 public function __construct()
 {
     global $wp_query;
     add_filter('query_vars', array($this, 'registerPublicVar'));
     $this->action('template_redirect', 'processVar');
     $this->action('init', 'flushWPRewriteRules');
     $this->action('generate_rewrite_rules', 'rewriteRules');
     $this->action('init', 'registerWidgets');
     if (wpi_option('text_dir') != 'ltr' && !is_admin()) {
         add_filter('language_attributes', array($this, 'textDirection'));
     }
     if (wpi_option('relative_links')) {
         add_filter('wpi_links_home', 'rel');
         add_filter('wpi_links_single', 'rel');
         add_filter(wpiFilter::FILTER_LINKS, 'rel');
     }
     // http header
     $this->action('send_headers', 'httpHeader');
     if (wpi_option('banner')) {
         $this->action(wpiFilter::ACTION_SECTION_PREFIX . 'pathway_after', 'banner');
         $this->action(wpiFilter::ACTION_INTERNAL_CSS, 'bannerIntenalCSS');
     }
     // dtd
     $this->action(wpiFilter::ACTION_DOCUMENT_DTD, 'dtd', 1);
     if (!wpi_option('meta_rsd')) {
         remove_filter('wp_head', 'rsd_link', 10, 1);
     }
     if (!wpi_option('meta_livewriter')) {
         remove_filter('wp_head', 'wlwmanifest_link', 10, 1);
     }
     if (!wpi_option('meta_wp_generator')) {
         remove_filter('wp_head', 'wp_generator', 10, 1);
     }
     // head
     $this->action(wpiFilter::ACTION_META_HTTP_EQUIV, 'metaHTTP');
     $this->action(wpiFilter::ACTION_META, 'meta');
     $this->action(wpiFilter::ACTION_META_LINK, 'metaLink');
     $this->action('wp_head', 'registerMetaActionFilters', 2);
     if (wpi_option('meta_title')) {
         $this->action('wp_head', 'headTitle', 1);
     }
     // custom content
     $this->action('wp_head', 'headCustomContent', wpiTheme::LAST_PRIORITY);
     $this->action('wp_footer', 'footerCustomContent', wpiTheme::LAST_PRIORITY);
     /**
      * Content
      */
     // header
     $this->action(wpiFilter::ACTION_TPL_HEADER, 'htmlBlogContentHeader');
     // content
     if (wpi_option('relative_date')) {
         if (!wpi_user_func_exists('time_since')) {
             Wpi::getFile('timesince', wpiTheme::LIB_TYPE_IMPORT);
         }
         wpi_foreach_hook_filter(array(wpiFilter::FILTER_POST_DATE, wpiFilter::FILTER_COM_DATE), 'wpi_get_relative_date');
     }
     add_action(wpiFilter::ACTION_SECTION_PREFIX . 'meta-title_content', 'wpi_content_meta_title_filter');
     $this->action(wpiFilter::ACTION_SECTION_PREFIX . 'content-end_content', 'navLink');
     if (!wpi_is_plugin_active('wp-pagenavi/wp-pagenavi.php')) {
         add_action(wpiFilter::ACTION_POST_PAGINATION, 'wpi_post_link');
     }
     add_filter(wpiFilter::FILTER_COMMENTS_SELECTOR, 'wpi_post_author_selector_filter');
     add_filter('get_comment_text', 'wpi_get_comment_text_filter');
     // footer
     $this->action('wp_footer', 'footerCopyright', 1);
     $this->action(wpiFilter::ACTION_COPYRIGHT_STATEMENTS, 'validationServices');
     add_action('wp_footer', 'wpi_register_widgets');
 }