From 0542556ee13329c0ed1f46e27f48bf2e14e9fd09 Mon Sep 17 00:00:00 2001 From: Marwane Kalam-Alami Date: Sat, 18 Jun 2016 12:29:36 +0200 Subject: [PATCH] add options page to configure the c2_navigation block --- compo/plugins/compo2/compo2.php | 3 ++ compo/plugins/compo2/mike.php | 39 ++++++++++++++++- compo/plugins/compo2/options.php | 72 ++++++++++++++++++++++++++++++++ compo/themes/ludum/index.php | 6 +-- 4 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 compo/plugins/compo2/options.php diff --git a/compo/plugins/compo2/compo2.php b/compo/plugins/compo2/compo2.php index 502cdaba5..6138b124a 100644 --- a/compo/plugins/compo2/compo2.php +++ b/compo/plugins/compo2/compo2.php @@ -393,6 +393,7 @@ function compo2_number_format($v) { require_once dirname(__FILE__)."/install.php"; +require_once dirname(__FILE__)."/options.php"; require_once dirname(__FILE__)."/main.php"; require_once dirname(__FILE__)."/active.php"; @@ -405,6 +406,8 @@ function compo2_number_format($v) { require_once dirname(__FILE__)."/mike.php"; +add_action('admin_menu', 'compo2_options_menu'); + //add_filter('the_content','compo2_the_content'); //add_action('wp_head', 'compo2_wp_head'); add_action('compo2_cache_begin', 'compo2_cache_begin'); diff --git a/compo/plugins/compo2/mike.php b/compo/plugins/compo2/mike.php index 279c2b6c8..37097b7a7 100644 --- a/compo/plugins/compo2/mike.php +++ b/compo/plugins/compo2/mike.php @@ -36,9 +36,44 @@ function c2_set_game($event_id,$user_id,$game) { } // This Function is called in the style sheet to display Navigation // -function c2_navigation($slug,$name,$name_url) { +function c2_navigation() { + //if ( !is_paged() ) { // First Page Only // - { + + // Fetch navigation enabled + if (function_exists('apcu_fetch')) { + $navInfo = apcu_fetch('c2_navigation_cache'); + if ($navInfo) { + $enabled = $navInfo['enabled']; + } + } + if (!$navInfo) { + $enabled = get_option('c2_navigation_enable'); + } + + if ($enabled) { + + // Fetch navigation options + if ($navInfo) { + $slug = $navInfo['slug']; + $name = $navInfo['name']; + $name_url = $navInfo['name_url']; + } + else { + $slug = get_option('c2_navigation_slug'); + $name = get_option('c2_navigation_name'); + $name_url = get_option('c2_navigation_name_url'); + if (function_exists('apcu_store')) { + apcu_store('c2_navigation_cache', array( + 'enabled' => $enabled, + 'slug' => $slug, + 'name' => $name, + 'name_url' => $name_url + )); + } + } + + // Fetch user/event info $user_id = get_current_user_id(); $event_id = 0; $underscore_slug = str_replace( '-', '_', $slug ); diff --git a/compo/plugins/compo2/options.php b/compo/plugins/compo2/options.php new file mode 100644 index 000000000..ea79f7762 --- /dev/null +++ b/compo/plugins/compo2/options.php @@ -0,0 +1,72 @@ +Compo2 Options'; + if (isset($showSavedMessage)) { + echo '

Settings saved.

'; + } + + ?> + +

Navigation block

+

These settings control the homepage block featuring handy links to the user entry and the event in general. It should be enabled from the kickoff of the event to the end of the rating phase.

+ +
+ + + + + + + + + + + + + + + + +
Event page ID
Event name
Announcement post URL
+ +

+ /> + +

+ + + +
+ + + diff --git a/compo/themes/ludum/index.php b/compo/themes/ludum/index.php index 9a708dc34..c1c71abce 100644 --- a/compo/themes/ludum/index.php +++ b/compo/themes/ludum/index.php @@ -7,11 +7,7 @@