public function processForm($data) { if (!isset($data['post'])) { return; } $form = $data['post']; $message = $data['message']; $notification = $data['notification']; $messages = $data['messages']; $this->setFormData($form->ID, $form->post_title); // register field values $this->processFormForStrings($form->post_content, 'Value: '); // register form title $this->registerString('Form Title: ' . $form->post_title, $form->post_title); $this->registerString('Display Message: ' . $form->post_title, $message); // register Notification Data also if ($notification && isset($notification->notifications) && is_array($notification->notifications)) { foreach ($notification->notifications as $ii => $nott) { // new format // these are not relevant in new format for localization /*switch($nott['to']['type']) { case 'wp_user': $this->registerString('CRED Notification '.$ii.' Mail To', $nott['to']['user']); break; case 'specific_mail': $this->registerString('CRED Notification '.$ii.' Mail To', $nott['to']['address']); if (isset($nott['to']['name'])) $this->registerString('CRED Notification '.$ii.' Mail To Name', $nott['to']['name']); if (isset($nott['to']['lastname'])) $this->registerString('CRED Notification '.$ii.' Mail To LastName', $nott['to']['lastname']); break; default: break; }*/ $hashSubject = CRED_Helper::strHash($nott['mail']['subject']); $hashBody = CRED_Helper::strHash($nott['mail']['body']); $this->registerString('CRED Notification Subject ' . $hashSubject, $nott['mail']['subject']); $this->registerString('CRED Notification Body ' . $hashBody, $nott['mail']['body']); } } // register messages also foreach ($messages as $msgid => $msg) { $this->registerString('Message_' . $msgid, $msg); } // register options from select and checkboxes/radio fields, force form build CRED_Loader::load('CLASS/Form_Builder'); CRED_Form_Builder::init(); CRED_Form_Builder::getForm($form->ID, null, false); // allow 3rd-party to add extra localization do_action('cred_localize_form', $data); }
/** * Initialize plugin enviroment */ public static function init() { global $wp_version, $post; // load translations from locale load_plugin_textdomain('wp-cred', false, CRED_LOCALE_PATH); // load help settings (once) self::$help = CRED_Loader::getHelpSettings(); // set up models and db settings self::prepareDB(); self::$settingsPage = admin_url('admin.php') . '?page=CRED_Settings'; if (is_admin()) { // setup js, css assets add_action('admin_enqueue_scripts', array('CRED_CRED', 'cred_admin_head')); // add plugin menus add_action('admin_menu', array('CRED_CRED', 'addMenuItems')); // add media buttons for cred forms at editor if (version_compare($wp_version, '3.1.4', '>')) { add_action('media_buttons', array('CRED_CRED', 'addFormsButton'), 20, 2); } else { add_action('media_buttons_context', array('CRED_CRED', 'addFormsButton'), 20, 2); } // integrate with Views add_filter('wpv_meta_html_add_form_button', array('CRED_CRED', 'addCREDButton'), 20, 2); // add custom meta boxes for cred forms add_action('add_meta_boxes_' . CRED_FORMS_CUSTOM_POST_NAME, array('CRED_CRED', 'addMetaBoxes'), 20, 1); // save custom fields of cred forms add_action('save_post', array('CRED_CRED', 'saveFormCustomFields'), 10, 2); //add_filter( 'default_content', array('CRED_CRED','formDefaultValues'), 10, 2 ); add_filter('wp_insert_post_data', array('CRED_CRED', 'forcePrivateforForms')); // add custom js on certain pages if (version_compare($wp_version, '3.3', '>=')) { //add_action('admin_head-edit.php', array($this, 'admin_add_help')); add_action('admin_head-post.php', array('CRED_CRED', 'jsForCredCustomPost')); add_action('admin_head-post-new.php', array('CRED_CRED', 'jsForCredCustomPost')); } if (version_compare($wp_version, '3.2', '>=')) { if (isset($post) && $post->post_type == CRED_FORMS_CUSTOM_POST_NAME) { remove_action('pre_post_update', 'wp_save_post_revision'); } } } else { // add form short code hooks and filters, to display forms on front end self::addShortcodesandFilters(); } // stub wpml-string shortcode if (!self::check_wpml_string()) { // WPML string translation is not active // Add our own do nothing shortcode add_shortcode('wpml-string', array('CRED_CRED', 'stub_wpml_string_shortcode')); } else { $wpml_was_active = get_option(self::$cred_wpml_option); // if changes before wpml activated, re-process all forms if ($wpml_was_active && $wpml_was_active == 'no') { //cred_log('process all forms'); CRED_Loader::load('CLASS/Form_Processor'); $cfp = new CRED_Form_Processor(null, null); $cfp->processAllFormsForStrings(); update_option(self::$cred_wpml_option, 'yes'); } } // setup custom capabilities self::setupCustomCaps(); // setup extra admin hooks for other plugins self::setupExtraHooks(); if (!is_admin()) { // init form processing to check for submits CRED_Loader::load('CLASS/Form_Builder'); CRED_Form_Builder::init(); } // handle custom routes, for (quasi) admin section CRED_Loader::load('CLASS/Router'); CRED_Router::init(); // handle Ajax calls CRED_Loader::load('CLASS/Ajax_Router'); CRED_Ajax_Router::init(); }
public static function _init_() { global $wp_version, $post; // load help settings (once) self::$help = CRED_Loader::getVar(CRED_INI_PATH . "/help.ini.php"); // set up models and db settings CRED_Helper::prepareDB(); // needed by others self::$settingsPage = admin_url('admin.php') . '?page=CRED_Settings'; // localize forms, support for WPML CRED_Helper::localizeForms(); // setup custom capabilities CRED_Helper::setupCustomCaps(); // setup custom user caps CRED_Helper::setupCustomUserCaps(); // setup extra admin hooks for other plugins CRED_Helper::setupExtraHooks(); if (is_admin()) { if (self::is_embedded()) { self::initAdmin(); } else { CRED_Admin::initAdmin(); } // if ($_GET['a']=='1') { // require_once CRED_CLASSES_PATH . "/CredUserFormCreator.php"; // CredUserFormCreator::cred_create_form(time(), 'edit', array('subscriber','author'), false, false, false); // } } else { // init form processing to check for submits CRED_Loader::load('CLASS/Form_Builder'); CRED_Form_Builder::init(); } // add form short code hooks and filters, to display forms on front end CRED_Helper::addShortcodesAndFilters(); // handle Ajax calls CRED_Router::addCalls(array('cred_skype_ajax' => array('nopriv' => true, 'callback' => array(__CLASS__, 'cred_skype_ajax')), 'cred-ajax-delete-post' => array('nopriv' => true, 'callback' => array(__CLASS__, 'cred_ajax_delete_post')))); CRED_Router::addRoutes('cred', array('Forms' => 0, 'Posts' => 0, 'Settings' => 0, 'Generic_Fields' => 0)); /* CRED_Router::addPages('cred', array( )); */ }