Commit 8685f048 by Cyrille37

typo

parent f824df73
......@@ -7,14 +7,17 @@
* Author: Cyrille GIQUELLO, Romain DUMINIL
*/
require_once "CommunityProject_install.php";
require_once "UserRoleController.php";
require_once "ProjectCustomTypeCreator.php";
require_once "ShortcodeController.php";
require_once ABSPATH . "/wp-content/plugins/CommunityVoice/Settings.php";
require_once 'CommunityProject_install.php';
require_once 'UserRoleController.php';
require_once 'ProjectCustomTypeCreator.php';
require_once 'ShortcodeController.php';
require_once ABSPATH . '/wp-content/plugins/CommunityVoice/Settings.php';
class CommunityProject
{
const CPT_TYPE = 'project';
const TERMS_STATUS = 'status' ;
const CP_DEBUG_MODE = false;
function __construct()
......@@ -23,21 +26,21 @@ class CommunityProject
register_deactivation_hook( __FILE__, array( new CommunityProject_install(), 'deactivate' ) );
register_uninstall_hook( __FILE__, array( 'CommunityProject_install', 'uninstall' ) );
add_action("plugins_loaded", array( $this, "add_CommunityVoice_setting" ));
add_action('plugins_loaded', array( $this, 'add_CommunityVoice_setting' ));
add_action( "init", array( new ProjectCustomTypeCreator(), "create_project_post_type" ) );
add_action( "init", array( new UserRoleController(), "create_student_role" ) );
add_action( "init", array( new ProjectCustomTypeCreator(), "create_status_taxonomy" ) );
add_action( "init", array( new ProjectCustomTypeCreator(), "create_default_status_terms" ) );
add_action( "init", array( new UserRoleController(), "set_user_role_permission" ) );
add_action( 'init', array( new ProjectCustomTypeCreator(), 'create_project_post_type' ) );
add_action( 'init', array( new UserRoleController(), 'create_student_role' ) );
add_action( 'init', array( new ProjectCustomTypeCreator(), 'create_status_taxonomy' ) );
add_action( 'init', array( new ProjectCustomTypeCreator(), 'create_default_status_terms' ) );
add_action( 'init', array( new UserRoleController(), 'set_user_role_permission' ) );
add_action( "add_meta_boxes", array( $this, "add_custom_fields" ) );
add_action( "admin_menu", array( $this, "remove_meta_boxes" ) );
add_action( "admin_menu", array( $this, "redirect_if_not_author" ) );
add_action( "do_meta_boxes", array( $this, "remove_edit_flow_metabox" ) );
add_action( 'add_meta_boxes', array( $this, 'add_custom_fields' ) );
add_action( 'admin_menu', array( $this, 'remove_meta_boxes' ) );
add_action( 'admin_menu', array( $this, 'redirect_if_not_author' ) );
add_action( 'do_meta_boxes', array( $this, 'remove_edit_flow_metabox' ) );
add_action( 'save_post', array( $this, 'set_default_status' ) );
add_action( 'after_setup_theme', array( $this, 'remove_admin_bar') );
add_action( "save_post", array( $this, "save_custom_meta_box" ), 10, 3 );
add_action( 'save_post', array( $this, 'save_custom_meta_box' ), 10, 3 );
add_filter('screen_options_show_screen', array( $this, 'remove_screen_options_tab' ) );
......@@ -46,7 +49,7 @@ class CommunityProject
function redirect_if_not_author()
{
if ( isset( $_GET['post'] ) && $_GET['action'] === 'edit' && get_post( $_GET['post'] )->post_type === "project" )
if ( isset( $_GET['post'] ) && $_GET['action'] === 'edit' && get_post( $_GET['post'] )->post_type === self::CPT_TYPE )
{
if( ! current_user_can( 'publish_posts' ) && get_post($_GET['post'])->post_author != get_current_user_id() )
{
......@@ -55,7 +58,8 @@ class CommunityProject
}
}
function remove_admin_bar() {
function remove_admin_bar()
{
if ( current_user_can( 'student_role' ) && ! is_admin() )
{
show_admin_bar( false );
......@@ -71,7 +75,7 @@ class CommunityProject
{
$Settings = new Settings();
$Settings->saveSetting( "CPT_only", "project" );
$Settings->saveSetting( 'CPT_only', 'project' );
}
/**
......@@ -81,12 +85,12 @@ class CommunityProject
function set_default_status( $post_id )
{
$post = get_post( $post_id );
if ( $post->post_type === "project" )
if ( $post->post_type === self::CPT_TYPE )
{
$terms = wp_get_post_terms( $post_id, "status" );
$terms = wp_get_post_terms( $post_id, self::TERMS_STATUS );
if ( empty( $terms ) )
{
wp_set_object_terms( $post_id, "depose", "status" );
wp_set_object_terms( $post_id, 'depose', self::TERMS_STATUS );
}
}
}
......@@ -137,7 +141,7 @@ class CommunityProject
function save_custom_meta_box( $post_id, $post, $update )
{
if( $post->post_type !== 'project' )
if( $post->post_type !== self::CPT_TYPE )
return;
if( $update === true )
......@@ -168,7 +172,6 @@ class CommunityProject
echo ob_get_clean();
}
}
new CommunityProject();
......@@ -46,7 +46,7 @@ class ProjectCustomTypeCreator
function create_status_taxonomy()
{
register_taxonomy( 'status', 'project', [
register_taxonomy( CommunityProject::TERMS_STATUS, CommunityProject::CPT_TYPE, [
'hierarchical' => true,
'labels' => [
'name' => 'Status',
......@@ -64,9 +64,9 @@ class ProjectCustomTypeCreator
'rewrite' => true]
);
register_taxonomy_for_object_type( 'status', 'project' );
register_taxonomy_for_object_type( CommunityProject::TERMS_STATUS, CommunityProject::CPT_TYPE );
register_taxonomy( 'category_projects', 'project', array(
register_taxonomy( 'category_projects', CommunityProject::CPT_TYPE, array(
'labels' => [
'name' => 'Catégories des projets',
'singular_name' => 'Catégorie du projet',
......@@ -91,18 +91,19 @@ class ProjectCustomTypeCreator
),
));
register_taxonomy_for_object_type( 'category_projects', 'project' );
register_taxonomy_for_object_type( 'category_projects', CommunityProject::CPT_TYPE );
}
function create_default_status_terms()
{
$terms = [
["taxonomy" => "status", "name" => "Déposé", "description" => "Projet déposé", "slug" => "depose" ],
["taxonomy" => "status", "name" => "Étude de la faisabilité", "description" => "Étude de la faisabilité", "slug" => "etude" ],
["taxonomy" => "status", "name" => "En cours de vote", "description" => "Projet en cours de vote", "slug" => "vote" ],
["taxonomy" => "status", "name" => "Validé", "description" => "Mise en œuvre du projet", "slug" => "valide" ],
["taxonomy" => "status", "name" => "Annulé", "description" => "Projet annulé", "slug" => "annule" ],
["taxonomy" => "status", "name" => "Refusé", "description" => "Projet refusé", "slug" => "refuse" ],
['taxonomy' => CommunityProject::TERMS_STATUS, 'name' => 'Déposé', 'description' => 'Projet déposé', 'slug' => 'depose' ],
['taxonomy' => CommunityProject::TERMS_STATUS, 'name' => 'Étude de la faisabilité', 'description' => 'Étude de la faisabilité', 'slug' => 'etude' ],
['taxonomy' => CommunityProject::TERMS_STATUS, 'name' => 'En cours de vote', 'description' => 'Projet en cours de vote', 'slug' => 'vote' ],
['taxonomy' => CommunityProject::TERMS_STATUS, 'name' => 'Validé', 'description' => 'Mise en œuvre du projet', 'slug' => 'valide' ],
['taxonomy' => CommunityProject::TERMS_STATUS, 'name' => 'Annulé', 'description' => 'Projet annulé', 'slug' => 'annule' ],
['taxonomy' => CommunityProject::TERMS_STATUS, 'name' => 'Refusé', 'description' => 'Projet refusé', 'slug' => 'refuse' ],
/*
["taxonomy" => "category_projects", "name" => "Sport", "description" => "Sport", "slug" => "sport" ],
["taxonomy" => "category_projects", "name" => "Musique", "description" => "Musique", "slug" => "musique" ],
......@@ -116,9 +117,9 @@ class ProjectCustomTypeCreator
foreach( $terms as $term )
{
wp_insert_term(
$term["name"],
$term["taxonomy"],
[ 'description'=> $term["description"], 'slug' => $term["slug"]]
$term['name'],
$term['taxonomy'],
[ 'description'=> $term['description'], 'slug' => $term['slug']]
);
}
}
......
......@@ -4,13 +4,13 @@ class ShortcodeController
{
function __construct()
{
add_shortcode( "project_nbr", array( $this, "get_project_nbr" ) );
add_shortcode( "add_project_link", array( $this, "add_project_link" ) );
add_shortcode( 'project_nbr', array( $this, 'get_project_nbr' ) );
add_shortcode( 'add_project_link', array( $this, 'add_project_link' ) );
add_shortcode( "display_project_nbr", array( $this, "display_project_nbr" ) );
add_shortcode( "display_add_project", array( $this, "display_add_project" ) );
add_shortcode( 'display_project_nbr', array( $this, 'display_project_nbr' ) );
add_shortcode( 'display_add_project', array( $this, 'display_add_project' ) );
add_shortcode( "display_proposed_project_text", array( $this, "display_proposed_project_text" ) );
add_shortcode( 'display_proposed_project_text', array( $this, 'display_proposed_project_text' ) );
}
function add_project_link()
......@@ -48,7 +48,7 @@ class ShortcodeController
$content = $projectNbr > 1 ? $a['plurial'] : $a['singular'];
ob_start();
include 'templates/project_number.php';
include 'templates/project_number.php' ;
return ob_get_clean();
}
......@@ -56,9 +56,10 @@ class ShortcodeController
{
$projectNbr = $this->get_project_nbr();
$a = shortcode_atts( array(
'singular' => "projet déposé",
'plurial' => "projets déposés",
'singular' => 'projet déposé',
'plurial' => 'projets déposés',
), $atts );
return $projectNbr > 1 ? $a['plurial'] : $a['singular'];
}
}
......@@ -31,14 +31,17 @@ class UserRoleController
[
'delete_posts' => false,
'edit_posts' => false,
'edit_projects' => true,
'delete_projects' => false,
'publish_projects' => true,
'edit_project' => true,
'delete_projects' => false,
'publish_projects' => true,
'read_private_projects' => false,
'edit_project' => true,
'read_project' => false,
'delete_project' => false,
'read_private_projects' => false,
'upload_files' => true,
'upload_files' => true,
'read' => true,
'level_1' => true
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment