예제 #1
0
function wptouch_load_add_ons()
{
    require_once WPTOUCH_DIR . '/core/file-operations.php';
    $php_files = wptouch_get_all_recursive_files(WPTOUCH_DIR . '/include/add-ons/', '.php');
    if ($php_files && count($php_files)) {
        foreach ($php_files as $php_file) {
            require_once WPTOUCH_DIR . '/include/add-ons' . $php_file;
        }
    }
}
function wptouch_page_templates_find_all_in_dir($dir)
{
    $templates = array();
    require_once WPTOUCH_DIR . '/core/file-operations.php';
    $files = wptouch_get_all_recursive_files($dir, '.php');
    foreach ($files as $file) {
        $content = wptouch_load_file($dir . '/' . $file);
        if (preg_match('#Mobile Template: (.*)#', $content, $matches)) {
            $template = new stdClass();
            $template->name = $matches[1];
            $template_parts = explode(DIRECTORY_SEPARATOR, $file);
            $template->location = $template_parts[count($template_parts) - 1];
            $templates[$file] = $template;
        }
    }
    return $templates;
}
예제 #3
0
function wptouch_get_all_recursive_files($dir, $file_types, $rel_path = '')
{
    $files = array();
    if (!is_array($file_types)) {
        $file_types = array($file_types);
    }
    $d = opendir($dir);
    if ($d) {
        while (($f = readdir($d)) !== false) {
            if ($f == '.' || $f == '..' || $f == '.svn') {
                continue;
            }
            if (is_dir($dir . '/' . $f)) {
                $files = array_merge($files, wptouch_get_all_recursive_files($dir . '/' . $f, $file_types, $rel_path . '/' . $f));
            } else {
                foreach ($file_types as $file_type) {
                    if (strpos($f, $file_type) !== false) {
                        $files[] = $rel_path . '/' . $f;
                        break;
                    }
                }
            }
        }
        closedir($d);
    }
    return $files;
}
예제 #4
0
파일: plugins.php 프로젝트: sumwander/unyil
function wptouch_plugins_generate_hook_list($wptouch_pro, $settings)
{
    require_once WPTOUCH_DIR . '/core/file-operations.php';
    $php_files = wptouch_get_all_recursive_files(WP_PLUGIN_DIR, '.php');
    $plugin_whitelist = apply_filters('wptouch_plugin_whitelist', array('hello', 'akismet', 'wptouch', 'wptouch-pro', 'wptouch-pro-image-optimizer', 'wptouch-pro-3'));
    $new_plugin_list = array();
    foreach ($php_files as $plugin_file) {
        $path_info = explode(DIRECTORY_SEPARATOR, $plugin_file);
        if ($path_info[1] != 'index.php') {
            $plugin_slug = $path_info[1];
            if (stristr($plugin_slug, '.php')) {
                $plugin_slug = substr($plugin_slug, 0, strpos($plugin_slug, '.php'));
            }
            if (in_array($plugin_slug, $plugin_whitelist)) {
                continue;
            }
            $plugin_file_path = WP_PLUGIN_DIR . $plugin_file;
            $contents = $wptouch_pro->load_file($plugin_file_path);
            if (!isset($new_plugin_list[$plugin_slug])) {
                $new_plugin_list[$plugin_slug] = new stdClass();
            }
            // Default actions
            if (preg_match_all("#add_action\\([ ]*[\\'\"]+(.*)[\\'\"]+,[ ]*[\\'\"]+(.*)[\\'\"]+[ ]*(\\s*[,]\\s*+(.*))*\\)\\s*;#iU", $contents, $matches)) {
                for ($i = 0; $i < count($matches[0]); $i++) {
                    if (strpos($matches[2][$i], ' ') === false) {
                        $info = new stdClass();
                        $info->hook = $matches[1][$i];
                        $info->hook_function = $matches[2][$i];
                        if (isset($matches[4][$i]) && $matches[4][$i] > 0) {
                            $info->priority = $matches[4][$i];
                        } else {
                            $info->priority = false;
                        }
                        $new_plugin_list[$plugin_slug]->actions[] = $info;
                    }
                }
            }
            // Default filters
            if (preg_match_all("#add_filter\\([ ]*[\\'\"]+(.*)[\\'\"]+,[ ]*[\\'\"]+(.*)[\\'\"]+[ ]*(\\s*[,]\\s*+(.*))*\\)\\s*;#iU", $contents, $matches)) {
                for ($i = 0; $i < count($matches[0]); $i++) {
                    if (strpos($matches[2][$i], ' ') === false) {
                        $info = new stdClass();
                        $info->hook = $matches[1][$i];
                        $info->hook_function = $matches[2][$i];
                        if (isset($matches[4][$i]) && $matches[4][$i] > 0) {
                            $info->priority = $matches[4][$i];
                        } else {
                            $info->priority = false;
                        }
                        $new_plugin_list[$plugin_slug]->filters[] = $info;
                    }
                }
            }
        }
    }
    // Create list of active plugins
    $active_plugins = get_option('active_plugins');
    if (!$active_plugins) {
        $active_plugins = array();
    }
    // Check for network activated plugins
    if (wptouch_is_multisite_enabled()) {
        $active_site_plugins = get_site_option('active_sitewide_plugins');
        if (is_array($active_site_plugins) && count($active_site_plugins)) {
            foreach ($active_site_plugins as $key => $value) {
                if (!in_array($key, $active_plugins)) {
                    $active_plugins[] = $key;
                }
            }
        }
    }
    $active_plugin_names = array();
    if (is_array($active_plugins) && count($active_plugins)) {
        foreach ($active_plugins as $plugin) {
            if (!($name = substr($plugin, 0, strpos($plugin, DIRECTORY_SEPARATOR)))) {
                $name = substr($plugin, 0, strpos($plugin, '.php'));
            }
            $active_plugin_names[] = $name;
        }
    }
    $final_hook_list = array();
    if (count($new_plugin_list)) {
        // Filter based on this list
        $usable_plugins = array();
        foreach ($new_plugin_list as $name => $info) {
            if (in_array($name, $active_plugin_names)) {
                $final_hook_list[$name] = $info;
            }
        }
    }
    $wptouch_pro->plugin_hooks = apply_filters('wptouch_plugin_exclusion_list', $final_hook_list);
    @ksort($wptouch_pro->plugin_hooks);
    $settings->plugin_hooks = $wptouch_pro->plugin_hooks;
    $settings->save();
}