diff --git a/plugins/fipfcard_plugin/fipfcard_plugin.php b/plugins/fipfcard_plugin/fipfcard_plugin.php index 0bdba3b..7f95831 100644 --- a/plugins/fipfcard_plugin/fipfcard_plugin.php +++ b/plugins/fipfcard_plugin/fipfcard_plugin.php @@ -24,71 +24,29 @@ include_once( plugin_dir_path(__FILE__) . '/utils/plgntls_class.php'); PLGNTLS_class::set_root_dir( plugin_dir_path(__FILE__), plugin_dir_url(__FILE__) ); + + /* * general inclusions */ -include_once(PLGNTLS_class::get_path() . '/utils/globals.php'); -include_once(PLGNTLS_class::get_path() . '/utils/console_log.php'); +include_once(PLGNTLS_class::get_path() . 'php/utils/globals.php'); -include_once(PLGNTLS_class::get_path() . '/php/paypal/paypal.php'); +include_once(PLGNTLS_class::get_path() . 'utils/console_log.php'); -include_once(PLGNTLS_class::get_path() . '/php/register/partenaires.php'); +include_once(PLGNTLS_class::get_path() . 'php/admin_menu/example_menu.php'); +include_once(PLGNTLS_class::get_path() . 'php/paypal/paypal.php'); - -/* -* test the class PLGNTLS -*/ -add_shortcode('fipfcard_plugin', 'fipfcard_test_class_tools'); +//include_once(PLGNTLS_class::get_path() . '/php/user_infos.php'); +//include_once(PLGNTLS_class::get_path() . '/php/hide_admin.php'); +//include_once(PLGNTLS_class::get_path() . '/php/menus.php'); +include_once(PLGNTLS_class::get_path() . 'php/register_partenaires.php'); +include_once(PLGNTLS_class::get_path() . 'php/redirections.php'); +include_once(PLGNTLS_class::get_path() . 'php/author_restriction.php'); -/* -* -function custom_frontend_posting_form() { - $my_image = the_field('image_ratio'); - error_log("my_image"); - error_log(json_encode($my_image)); - return $my_image; -} -add_shortcode('custom_frontend_posting_form', 'custom_frontend_posting_form'); -*/ - - - - - - - - - - - - - - - - - - - -/* -* menu plugin -*/ -include_once(PLGNTLS_class::get_path() . '/php/menu/example_menu.php'); -function fipfcard_plugin_menu() -{ - add_menu_page - ( - 'fipf_card', // webpage title - 'fipf_card', // menu title - 'manage_options', // capability - 'fipfcard-plugin', // menu_slug - 'fipfcard_plugin_content' // callback function to display page content - ); -} -add_action('admin_menu', 'fipfcard_plugin_menu'); diff --git a/plugins/fipfcard_plugin/php/menu/example_menu.php b/plugins/fipfcard_plugin/php/admin_menu/example_menu.php similarity index 72% rename from plugins/fipfcard_plugin/php/menu/example_menu.php rename to plugins/fipfcard_plugin/php/admin_menu/example_menu.php index 2e50968..2e154ba 100644 --- a/plugins/fipfcard_plugin/php/menu/example_menu.php +++ b/plugins/fipfcard_plugin/php/admin_menu/example_menu.php @@ -1,5 +1,33 @@ diff --git a/plugins/fipfcard_plugin/php/hide_admin.php b/plugins/fipfcard_plugin/php/hide_admin.php new file mode 100644 index 0000000..dbbe7a0 --- /dev/null +++ b/plugins/fipfcard_plugin/php/hide_admin.php @@ -0,0 +1,25 @@ + diff --git a/plugins/fipfcard_plugin/php/images/acf_form.php b/plugins/fipfcard_plugin/php/images/acf_form.php index 0887e0d..4d21bc6 100644 --- a/plugins/fipfcard_plugin/php/images/acf_form.php +++ b/plugins/fipfcard_plugin/php/images/acf_form.php @@ -1,3 +1,14 @@ + + diff --git a/plugins/fipfcard_plugin/php/menus.php b/plugins/fipfcard_plugin/php/menus.php new file mode 100644 index 0000000..e64c44b --- /dev/null +++ b/plugins/fipfcard_plugin/php/menus.php @@ -0,0 +1,43 @@ + Menus + * 2. dans le code ci-dessous, changer la valeur de $menu_title pour correspondre au titre du menu + * 3. et si besoin changer la valeur de $menu_redirect pour choisir la page de redirection : + * - si laissée vide, la redirection se fera sur la page de connexion de wordpress + * - avec $current_url la redirection se fera sur la page actuelle + * - avec $base_url on redirige vers la page d'accueil du site (l'url sans chemin supplementaire) + * cette variable $base_url peut etre utilisee pour construire une autre url : + * - $menu_redirect = $base_url -> https://le_site_actuel.com/ + * - $menu_redirect = $base_url . 'contact' -> https://le_site_actuel.com/contact + * - $menu_redirect = $current_url -> https://le_site_actuel.com/la_meme_page + * - $menu_redirect = 'www.un_autre_site.net/contact' -> https://www.un_autre_site.net/contact + */ +function change_menu($items){ + $menu_title = 'special logout'; + + // quelques urls utiles : + $base_url = home_url(); + $current_url = home_url( $_SERVER['REQUEST_URI'] ); + + $menu_redirect = ''; + foreach($items as $item){ + if( $item->title === $menu_title){ + $item->url = wp_nonce_url( wp_logout_url( $menu_redirect ), 'log-out' ); + } + } + return $items; +} +add_filter('wp_nav_menu_objects', 'change_menu'); + + +?> diff --git a/plugins/fipfcard_plugin/php/paypal/route_api_orders.php b/plugins/fipfcard_plugin/php/paypal/route_api_orders.php index bccf68c..e39b96f 100644 --- a/plugins/fipfcard_plugin/php/paypal/route_api_orders.php +++ b/plugins/fipfcard_plugin/php/paypal/route_api_orders.php @@ -1,8 +1,5 @@ 'project', + 'author' => $current_user_id, + 'posts_per_page' => 1, + ); + $query = reset(get_posts($args)); + $post_id = $query->ID; + $redirect_url = get_permalink($query->ID); + wp_redirect($redirect_url, 301); + } + exit; +} +add_action('template_redirect', 'redirection_page_CIPF'); + + + +?> diff --git a/plugins/fipfcard_plugin/php/register/partenaires.php b/plugins/fipfcard_plugin/php/register/partenaires.php deleted file mode 100644 index ef0db84..0000000 --- a/plugins/fipfcard_plugin/php/register/partenaires.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/plugins/fipfcard_plugin/php/register_partenaires.php b/plugins/fipfcard_plugin/php/register_partenaires.php new file mode 100644 index 0000000..049864e --- /dev/null +++ b/plugins/fipfcard_plugin/php/register_partenaires.php @@ -0,0 +1,29 @@ + diff --git a/plugins/fipfcard_plugin/php/user_infos.php b/plugins/fipfcard_plugin/php/user_infos.php new file mode 100644 index 0000000..ab5dbf3 --- /dev/null +++ b/plugins/fipfcard_plugin/php/user_infos.php @@ -0,0 +1,29 @@ +user_email; + } + else { + return $text_not_logged_in; + } +} +add_shortcode('cipf_user_email', 'current_user_email_shortcode'); + + +?> diff --git a/plugins/fipfcard_plugin/php/utils/globals.php b/plugins/fipfcard_plugin/php/utils/globals.php new file mode 100644 index 0000000..f085920 --- /dev/null +++ b/plugins/fipfcard_plugin/php/utils/globals.php @@ -0,0 +1,54 @@ + diff --git a/plugins/fipfcard_plugin/utils/globals.php b/plugins/fipfcard_plugin/utils/globals.php deleted file mode 100644 index febeb5c..0000000 --- a/plugins/fipfcard_plugin/utils/globals.php +++ /dev/null @@ -1,55 +0,0 @@ - diff --git a/plugins/fipfcard_plugin/utils/plgntls_class.php b/plugins/fipfcard_plugin/utils/plgntls_class.php index 13c5b8f..d2c706d 100644 --- a/plugins/fipfcard_plugin/utils/plgntls_class.php +++ b/plugins/fipfcard_plugin/utils/plgntls_class.php @@ -1,5 +1,13 @@