Ejemplo n.º 1
0
 function synved_option_item_addon_install($id, $name, $item)
 {
     $return = null;
     $type = synved_option_item_type($item);
     $target = synved_option_item_property($item, 'target');
     $folder = synved_option_item_property($item, 'folder');
     $field_name = synved_option_name_default($id);
     $path = null;
     if (file_exists($target)) {
         $path = $target;
     }
     if ($type != 'addon' || $path == null) {
         return false;
     }
     $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
     if (substr($path, -1) != DIRECTORY_SEPARATOR) {
         $path .= DIRECTORY_SEPARATOR;
     }
     if (isset($_FILES[$field_name])) {
         foreach ($_FILES[$field_name]["error"] as $key => $error) {
             if ($key == $name && $error == UPLOAD_ERR_OK) {
                 $tmp_name = $_FILES[$field_name]["tmp_name"][$key];
                 $name = $_FILES[$field_name]["name"][$key];
                 $tmpfname = wp_tempnam($name . '.zip');
                 if (move_uploaded_file($tmp_name, $tmpfname)) {
                     global $wp_filesystem;
                     $unzip_path = realpath($path);
                     $dirs = glob($path . '*', GLOB_ONLYDIR);
                     if ($wp_filesystem != null) {
                         $unzip_path = $wp_filesystem->find_folder($unzip_path);
                     }
                     wp_mkdir_p(realpath($path));
                     $return = unzip_file($tmpfname, $unzip_path);
                     if ($wp_filesystem != null) {
                         $wp_filesystem->delete($tmpfname);
                     }
                     $dirs_new = glob($path . '*', GLOB_ONLYDIR);
                     $dirs_diff = array_values(array_diff($dirs_new, $dirs));
                     $addon_path = $path;
                     if ($dirs_diff != null) {
                         $folder_path = null;
                         foreach ($dirs_diff as $dir) {
                             if (basename($dir) == $folder) {
                                 $folder_path = $dir;
                             }
                         }
                         // XXX no correct path, was unzip successful?
                         if ($folder_path == null) {
                             $folder_path = $dirs_diff[0];
                         }
                         $addon_path = $folder_path;
                     }
                     synved_option_set($id, $name, $addon_path);
                 }
             }
         }
     }
     return $return;
 }
Ejemplo n.º 2
0
function synved_option_wp_admin_init()
{
    global $synved_option_list;
    if ($synved_option_list != null) {
        foreach ($synved_option_list as $id => $list) {
            $dbname = synved_option_name_default($id);
            $group = synved_option_group_default($id);
            register_setting($group, $dbname, create_function('$value', 'return synved_option_setting_sanitize_cb(\'' . $id . '\', $value);'));
            $items = synved_option_item_list($id);
            foreach ($items as $name => $item) {
                synved_option_wp_handle_setting($id, null, null, $name, $item);
            }
        }
    }
}
function synved_option_render_field_id($id, $name)
{
    $out_id = synved_option_name_default($id) . '_' . $name;
    return $out_id;
}
Ejemplo n.º 4
0
function synved_shortcode_admin_enqueue_scripts()
{
    $uri = synved_shortcode_path_uri();
    synved_shortcode_wp_register_common_scripts();
    wp_register_script('jquery-chosen', $uri . '/chosen/chosen.jquery.js', array('jquery'), '0.9.8');
    wp_register_script('synved-shortcode-script-admin', $uri . '/script/admin.js', array('synved-shortcode-base', 'jquery', 'suggest', 'media-upload', 'thickbox', 'jquery-ui-core', 'jquery-ui-progressbar', 'jquery-ui-dialog'), '1.0.0');
    wp_localize_script('synved-shortcode-script-admin', 'SynvedShortcodeVars', array('flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'ajaxurl' => admin_url('admin-ajax.php'), 'synvedSecurity' => wp_create_nonce('synved-shortcode-submit-nonce'), 'mainUri' => $uri, 'currentPost' => isset($_GET['post']) ? $_GET['post'] : 0));
    wp_register_style('synved-shortcode-admin', $uri . '/style/admin.css', array('thickbox', 'wp-pointer', 'wp-jquery-ui-dialog'), '1.0');
    wp_register_style('jquery-chosen', $uri . '/chosen/chosen.css', false, '0.9.8');
    $file = isset($GLOBALS['pagenow']) ? $GLOBALS['pagenow'] : null;
    $page = isset($_GET['page']) ? $_GET['page'] : null;
    $enqueue = false;
    if ($file == 'post.php' || $file == 'post-new.php' || $file == 'options-general.php' && $page == synved_option_name_default('synved_shortcode')) {
        $enqueue = true;
    }
    if ($enqueue) {
        wp_enqueue_style('synved-shortcode-jquery-ui');
        wp_enqueue_style('farbtastic');
        wp_enqueue_style('jquery-chosen');
        wp_enqueue_style('synved-shortcode-layout');
        wp_enqueue_style('synved-shortcode-jquery-ui-custom');
        wp_enqueue_style('synved-shortcode-admin');
        wp_enqueue_script('plupload-all');
        wp_enqueue_script('media-upload');
        wp_enqueue_script('suggest');
        wp_enqueue_script('thickbox');
        wp_enqueue_script('farbtastic');
        wp_enqueue_script('jquery-chosen');
        wp_enqueue_script('synved-shortcode-script-admin');
    }
}