Ejemplo n.º 1
0
 /**
  * Activate the plugin
  */
 public static function activate()
 {
     global $Chronosly_Extend;
     //TODO MIRAR LA FUNCION add_role PARA AÑADIR ROLES DE USUARIOS NUEVOS
     // Capabilities for the chronosly custom post type
     $WP_Roles = new WP_Roles();
     foreach (array('chronosly_author', 'edit_' . CHRONOSLY_CAPABILITY_TYPE, 'read_' . CHRONOSLY_CAPABILITY_TYPE, 'delete_' . CHRONOSLY_CAPABILITY_TYPE, 'delete_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'edit_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'edit_others_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'edit_published_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'delete_published_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'delete_private_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'delete_others_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'publish_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'read_private_' . CHRONOSLY_CAPABILITY_TYPE . 's', 'chronosly_options', 'chronosly_license') as $cap) {
         $WP_Roles->add_cap(CHRONOSLY_ADMIN_ROLE, $cap);
     }
     $ext = new Chronosly_Extend();
     //the new code will set CHRONOSLY_VERSION code to the latest
     //update templates and addons
     $ext->update_addons();
     $ext->update_templates();
     $ext->rebuild_template_addons("default");
     Chronosly_Cache::clear_cache();
     wp_schedule_event(time(), "daily", 'chronosly_update_addons');
     wp_schedule_event(time(), "daily", 'chronosly_update_templates');
 }
                    }
                }
            } else {
                wp_die("The file type that you've uploaded is not a Chronosly Addons ZIP.");
            }
            // end if/else
        }
        // end if
    }
} else {
    if (isset($_REQUEST["update_addon"]) and $_REQUEST["update_addon"] and isset($_REQUEST['addon'])) {
        if (!current_user_can('manage_options')) {
            wp_die(__('You do not have sufficient permissions to access this page.'));
        }
        $ext = new Chronosly_Extend();
        echo $ext->update_addons($_REQUEST['addon']);
    } else {
        if (isset($_REQUEST["delete"])) {
            if (!current_user_can('manage_options')) {
                wp_die(__('You do not have sufficient permissions to access this page.'));
            }
            if (has_filter("chronosly_update_template_" . $_REQUEST["delete"])) {
                $Post_Type_Chronosly->template->full_update_templates_by_addon($_REQUEST["delete"], array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), "remove");
            }
            if (has_action("chronosly_remove_" . $_REQUEST["delete"])) {
                do_action("chronosly_remove_" . $_REQUEST["delete"]);
            }
            //remove files and reload page
            $utils = new Chronosly_Utils();
            $utils->rrmdir(CHRONOSLY_ADDONS_PATH . DIRECTORY_SEPARATOR . $_REQUEST["delete"]);
            // wp_redirect("admin.php?page=chronosly_addons_configs&deleted=1");