/** * Function called after settings are saved. * * @param String $formValuesFiltered The data values actually saved to the database after filtering. * @param String $originalFormValues The original data values before filtering. * @param Object $formObj The form object thats doing the saving. */ function WPCW_showPage_Settings_afterSave($formValuesFiltered, $originalFormValues, $formObj) { // Can't update licence key unless admin for site. if (!WPCW_plugin_hasAdminRights()) { return false; } }
/** * Function called after settings are saved. * * @param String $formValuesFiltered The data values actually saved to the database after filtering. * @param String $originalFormValues The original data values before filtering. * @param Object $formObj The form object thats doing the saving. */ function WPCW_showPage_Settings_afterSave($formValuesFiltered, $originalFormValues, $formObj) { // Can't update licence key unless admin for site. if (!WPCW_plugin_hasAdminRights()) { return false; } // Update the licence key for the plugin, in case it's changed. // global $updater_wpcw; // $updater_wpcw->setAccessKey($formValuesFiltered['licence_key'], true); }
/** * Initialisation functions for plugin. */ function WPCW_plugin_init() { // Load translation support $plugin_dir = basename(dirname(__FILE__)) . '/language/'; load_plugin_textdomain('wp_courseware', false, $plugin_dir); // Run setup WPCW_plugin_setup(false); // Change preferences for updater if (WPCW_plugin_hasAdminRights()) { global $updater_wpcw; $updater_wpcw->setAccessKey(TidySettings_getSettingSingle(WPCW_DATABASE_SETTINGS_KEY, 'licence_key')); //$updater_wpcw->plugin_msg_blocked = false; // No message if blocked licence. $updater_wpcw->plugin_msg_expired = __('Your licence key has expired. Please visit <a href="http://www.flyplugins.com" target="_blank">FlyPlugins.com</a> to renew your licence.', 'wp_courseware'); $updater_wpcw->plugin_msg_invalid = __('Please enter a valid licence key or visit <a href="http://www.flyplugins.com" target="_blank">FlyPlugins.com</a> to purchase a licence.', 'wp_courseware'); $updater_wpcw->plugin_msg_limit_reached = __('You\'ve reached the maximum number of websites for this licence. Please visit <a href="http://www.flyplugins.com" target="_blank">FlyPlugins.com</a> to upgrade your licence.', 'wp_courseware'); } // ### Admin if (is_admin()) { // Menus add_action('admin_menu', 'WPCW_menu_MainMenu'); add_action('admin_head', 'WPCW_menu_MainMenu_cleanUnwantedEntries'); // Network Only //add_action('network_admin_menu', 'WPCW_menu_MainMenu_NetworkOnly'); // Scripts and styles add_action('admin_print_scripts', 'WPCW_addCustomScripts_BackEnd'); add_action('admin_print_styles', 'WPCW_addCustomCSS_BackEnd'); // See if export has been requested WPCW_Export::tryExportCourse(); // Post Related add_action('save_post', 'WPCW_units_saveUnitPostMetaData', 10, 2); // User Related add_action('manage_users_columns', 'WPCW_users_manageColumns'); add_action('manage_users_custom_column', 'WPCW_users_addCustomColumnContent', 10, 3); // Unit Related add_filter('manage_course_unit_posts_columns', 'WPCW_units_manageColumns', 10); add_action('manage_course_unit_posts_custom_column', 'WPCW_units_addCustomColumnContent', 10, 2); // Unit Deletion add_filter('delete_post', 'WPCW_units_deleteUnitHandler'); // Meta boxes add_action('add_meta_boxes', 'WPCW_units_showConversionMetaBox'); // AJAX - Admin add_action('wp_ajax_wpcw_handle_unit_ordering_saving', 'WPCW_AJAX_handleUnitOrderingSaving'); // AJAX - Frontend (yeah, WP requires they go here) add_action('wp_ajax_wpcw_handle_unit_track_progress', 'WPCW_AJAX_units_handleUserProgress'); add_action('wp_ajax_wpcw_handle_unit_quiz_response', 'WPCW_AJAX_units_handleQuizResponse'); // Notices about permalinks add_action('admin_notices', 'WPCW_plugin_permalinkCheck'); add_action('admin_notices', 'WPCW_plugin_multisiteCheck'); // CSV Export add_action('wp_loaded', 'WPCW_data_handleDataExport'); } else { // Scripts and styles WPCW_addCustomScripts_FrontEnd(); // Shortcodes add_shortcode('wpcourse', 'WPCW_shortcodes_showTrainingCourse'); // Post Content add_filter('the_content', 'WPCW_units_processUnitContent'); } // Action when admin has updated the course details. add_action('wpcw_course_details_updated', 'WPCW_actions_courses_courseDetailsUpdated'); // Action when user has completed a unit/module/course add_action('wpcw_user_completed_unit', 'WPCW_actions_users_unitCompleted', 10, 3); add_action('wpcw_user_completed_module', 'WPCW_actions_users_moduleCompleted', 10, 3); add_action('wpcw_user_completed_course', 'WPCW_actions_users_courseCompleted', 10, 3); // Modified modules - when a module is created or edited add_action('wpcw_modules_modified', 'WPCW_actions_modules_modulesModified'); // Action called when user has been created, and we check to see if that user should be added to // any of the defined courses. add_action('user_register', 'WPCW_actions_users_newUserCreated'); // Action called when user has been deleted add_action('delete_user', 'WPCW_actions_users_userDeleted'); // Action called when quiz has been completed and needs grading. add_action('wpcw_quiz_needs_grading', 'WPCW_actions_userQuizNeedsGrading_notifyAdmin', 10, 2); // Action called when quiz has been graded. add_action('wpcw_quiz_graded', 'WPCW_actions_userQuizGraded_notifyUser', 10, 4); // Common WPCW_plugin_registerCustomPostTypes(); // Create correct URL for unit add_filter('post_type_link', 'WPCW_units_createCorrectUnitURL', 1, 3); // Create permalink for course units global $wp_rewrite; $unit_structure = '/%module_number%/%course_unit%/'; // Handle module and course unit tags $wp_rewrite->add_rewrite_tag("%module_number%", '(module-[^/]+)', "module_number="); $wp_rewrite->add_rewrite_tag("%course_unit%", '([^/]+)', "course_unit="); // Make it happen to format links automatically for course units. $wp_rewrite->add_permastruct('course_unit', $unit_structure, false); // Ensure the URLs are flushed for the first time $flushRules = get_option('wpcw_flush_rules'); if (!$flushRules) { update_option('wpcw_flush_rules', 'done'); $wp_rewrite->flush_rules(); } // Now load any extensions //do_action('wpcw_extensions_load'); }