public function exportAll($get, $post) { if (isset($get['all']) && isset($get['_wpnonce'])) { if (wp_verify_nonce($get['_wpnonce'], 'cred-export-all')) { CRED_Loader::load('CLASS/XML_Processor'); $filename = isset($get['filename']) ? urldecode($get['filename']) : ''; CRED_XML_Processor::exportToXML('all', isset($get['ajax']), $filename); die; } } die; }
} } else { $cred_import_file = null; } if ($cred_import_file !== null && !empty($cred_import_file)) { $options = array(); if (isset($_POST["cred-overwrite-forms"])) { $options['overwrite_forms'] = 1; } if (isset($_POST["cred-overwrite-settings"])) { $options['overwrite_settings'] = 1; } if (isset($_POST["cred-overwrite-custom-fields"])) { $options['overwrite_custom_fields'] = 1; } CRED_Loader::load('CLASS/XML_Processor'); $user_results = CRED_XML_Processor::importUserFromXML($cred_import_file, $options); } } $settings_model = CRED_Loader::get('MODEL/Settings'); $settings = $settings_model->getSettings(); $url = admin_url('admin.php') . '?page=CRED_Settings'; $doaction = isset($_POST['cred_settings_action']) ? $_POST['cred_settings_action'] : false; if ($doaction) { check_admin_referer('cred-settings-action', 'cred-settings-field'); switch ($doaction) { case 'edit': $settings = isset($_POST['settings']) ? (array) $_POST['settings'] : array(); if (!isset($settings['wizard'])) { $settings['wizard'] = 0; }
public function exportAll($get, $post) { if (!current_user_can(CRED_CAPABILITY)) { wp_die(); } if (isset($get['all']) && isset($get['_wpnonce'])) { if (wp_verify_nonce($get['_wpnonce'], 'cred-export-all')) { CRED_Loader::load('CLASS/XML_Processor'); //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173458/comments //Security Fix added validate_file and sanitize $filename = isset($get['filename']) && validate_file($get['filename']) ? urldecode($get['filename']) : ''; if (isset($get['type']) && $get['type'] == 'user') { CRED_XML_Processor::exportUsersToXML('all', isset($get['ajax']), $filename); } else { CRED_XML_Processor::exportToXML('all', isset($get['ajax']), $filename); } die; } } die; }
function cred_export_to_xml_string($forms) { CRED_Loader::load('CLASS/XML_Processor'); $xmlstring = CRED_XML_Processor::exportToXMLString($forms); return $xmlstring; }
wp_die(__('You can’t edit this item because it is in the Trash. Please restore it and try again.')); } $post_type = $post->post_type; if ('post' == $post_type) { $parent_file = "edit.php"; $submenu_file = "edit.php"; $post_new_file = "post-new.php"; } elseif ('attachment' == $post_type) { $parent_file = 'upload.php'; $submenu_file = 'upload.php'; $post_new_file = 'media-new.php'; } else { if (isset($post_type_object) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true) { $parent_file = $post_type_object->show_in_menu; } else { $parent_file = "edit.php?post_type={$post_type}"; } $submenu_file = "edit.php?post_type={$post_type}"; $post_new_file = "post-new.php?post_type={$post_type}"; } if ($last = wp_check_post_lock($post->ID)) { add_action('admin_notices', '_admin_notice_post_locked'); } else { $active_post_lock = wp_set_post_lock($post->ID); } $title = $post_type_object->labels->edit_item; $post = get_post($post_id, OBJECT, 'edit'); CRED_Loader::load('VIEW/edit-form-advanced'); break; } // end switch
public function __construct($form, $post_id = null, $preview = false, $force_form_count = false) { global $post, $current_user; // reference to the form submission method global ${'_' . self::METHOD}; $method =& ${'_' . self::METHOD}; // if types is not active, no CRED if (!function_exists('wpcf_init') || !defined('WPCF_ABSPATH')) { $this->error = __('Types plugin not active', 'wp-cred'); return; } self::initVars(); // get inputs if (isset($post_id) && !empty($post_id) && $post_id != false && !$preview) { $post_id = intval($post_id); } elseif (isset($post->ID) && !$preview) { $post_id = $post->ID; } else { $post_id = false; } // get recaptcha settings if (!self::$recaptcha_settings) { $sm = CRED_Loader::get('MODEL/Settings'); $gen_setts = $sm->getSettings(); if (isset($gen_setts['recaptcha']['public_key']) && isset($gen_setts['recaptcha']['private_key']) && !empty($gen_setts['recaptcha']['public_key']) && !empty($gen_setts['recaptcha']['private_key'])) { self::$recaptcha_settings = $gen_setts['recaptcha']; } } // load form data require_once ABSPATH . '/wp-admin/includes/post.php'; $fm = CRED_Loader::get('MODEL/Forms'); $this->_form = $fm->getForm($form); if ($this->_form === false) { $this->error = __('Form does not exist!', 'wp-cred'); return; } $this->_form_id = $this->_form->form->ID; // preview when form is not saved at all //print_r($this->_form); if (!isset($this->_form->fields) || !is_array($this->_form->fields) || empty($this->_form->fields) || !isset($this->_form->fields['form_settings'])) { $this->_form->fields = array('form_settings' => new stdClass(), 'extra' => new stdClass(), 'notification' => new stdClass()); if ($preview) { $this->error = __('Form preview does not exist. Try saving your form first', 'wp-cred'); return; } } $this->_redirect_delay = isset($this->_form->fields['form_settings']->redirect_delay) ? intval($this->_form->fields['form_settings']->redirect_delay) : self::DELAY; $this->_hide_comments = isset($this->_form->fields['form_settings']->hide_comments) && $this->_form->fields['form_settings']->hide_comments ? true : false; $form_id = $this->_form->form->ID; $cred_css_themes = array('minimal' => CRED_PLUGIN_URL . '/third-party/zebra_form/public/css/minimal.css', 'styled' => CRED_PLUGIN_URL . '/third-party/zebra_form/public/css/styled.css'); $this->_extra = array(); if ($preview) { if (array_key_exists(self::PREFIX . 'form_preview_post_type', $method)) { $this->_post_type = $this->_form->fields['form_settings']->post_type = stripslashes($method[self::PREFIX . 'form_preview_post_type']); } else { $this->error = __('Preview post type not provided', 'wp-cred'); return; } if (array_key_exists(self::PREFIX . 'form_preview_form_type', $method)) { $this->_form_type = stripslashes($method[self::PREFIX . 'form_preview_form_type']); } else { $this->error = __('Preview form type not provided', 'wp-cred'); return; } if (array_key_exists(self::PREFIX . 'form_preview_content', $method)) { $this->_preview_content = stripslashes($method[self::PREFIX . 'form_preview_content']); $this->_content = stripslashes($method[self::PREFIX . 'form_preview_content']); } else { $this->error = __('No preview form content provided', 'wp-cred'); return; } if (array_key_exists(self::PREFIX . 'form_css_to_use', $method)) { $this->css_to_use = trim(stripslashes($method[self::PREFIX . 'form_css_to_use'])); if (in_array($this->css_to_use, array_keys($cred_css_themes))) { $this->css_to_use = $cred_css_themes[$this->css_to_use]; } else { $this->css_to_use = $cred_css_themes['minimal']; } } else { $this->css_to_use = $cred_css_themes['minimal']; } if (array_key_exists(self::PREFIX . 'extra_css_to_use', $method)) { $this->_extra['css'] = trim(stripslashes($method[self::PREFIX . 'extra_css_to_use'])); } if (array_key_exists(self::PREFIX . 'extra_js_to_use', $method)) { $this->_extra['js'] = trim(stripslashes($method[self::PREFIX . 'extra_js_to_use'])); } } else { $this->_post_type = $this->_form->fields['form_settings']->post_type; $this->_form_type = $this->_form->fields['form_settings']->form_type; $this->_extra = isset($this->_form->fields['extra']) ? (array) $this->_form->fields['extra'] : array(); // get form content in order to replace it with actual form $this->_content = $this->_form->form->post_content; if (isset($this->_form->fields['form_settings']->cred_theme_css) && in_array($this->_form->fields['form_settings']->cred_theme_css, array_keys($cred_css_themes))) { $this->css_to_use = $cred_css_themes[$this->_form->fields['form_settings']->cred_theme_css]; } else { $this->css_to_use = $cred_css_themes['minimal']; } } if (!isset($this->_extra['messages'])) { if (isset($this->_form->fields['extra']) && isset($this->_form->fields['extra']->messages)) { $this->_extra['messages'] = $this->_form->fields['extra']->messages; } else { $this->_extra['messages'] = CRED_Loader::get('MODEL/Forms')->getDefaultMessages(); } } // if this is an edit form and no post id given if ($this->_form_type == 'edit' && $post_id === false && !$preview) { $this->error = __('No post specified', 'wp-cred'); return; } // if this is a new form and post id given if ($this->_form_type == 'new' && !$preview) { if (isset($method[self::PREFIX . 'post_id']) && intval($method[self::PREFIX . 'post_id']) > 0) { $post_id = intval($method[self::PREFIX . 'post_id']); } else { $post_id = get_default_post_to_edit($this->_post_type, true)->ID; } } $this->_post_id = $post_id; // increase counter //self::$form_count++; if ($force_form_count !== false) { $this->_form_count = $force_form_count; } else { $this->_form_count = self::$form_count; } // dependencies, uses Zebra_Form framework (see folder for details) CRED_Loader::load('THIRDPARTY/MyZebra_Parser'); CRED_Loader::load('THIRDPARTY/MyZebra_Form'); // instantiate form $this->_myzebra_form = new MyZebra_Form('cred_form_' . $form_id . '_' . $this->_form_count, self::METHOD, $this->currentURI(array('_tt' => time()), array('_success')), '', array()); if ($preview) { $this->_myzebra_form->preview = true; } else { $this->_myzebra_form->preview = false; } // form properties self::$ASSETS_PATH = DIRECTORY_SEPARATOR . 'third-party' . DIRECTORY_SEPARATOR . 'zebra_form' . DIRECTORY_SEPARATOR; self::$ASSETS_URL = '/third-party/zebra_form/'; $this->_myzebra_form->doctype('xhtml'); $this->_myzebra_form->client_side_validation(true); $this->_myzebra_form->show_all_error_messages(true); $this->_myzebra_form->assets_path(CRED_PLUGIN_PATH . self::$ASSETS_PATH, plugins_url() . '/' . CRED_PLUGIN_FOLDER . self::$ASSETS_URL); $locale = self::$localized_strings; $this->_myzebra_form->language($locale); // get custom post fields $ffm = CRED_Loader::get('MODEL/Fields'); $this->_fields = $ffm->getFields($this->_post_type); // in CRED 1.1 post_fields and custom_fields are different keys, merge them together to keep consistency $this->_fields['_post_fields'] = $this->_fields['post_fields']; $this->_fields['post_fields'] = array_merge($this->_fields['post_fields'], $this->_fields['custom_fields']); //cred_log(print_r($this->_fields,true)); // get existing post data if edit form and post given if ($this->_form_type == 'edit') { if ($post_id) { $res = $fm->getPost($post_id); if ($res && isset($res[0])) { $mypost = $res[0]; cred_log(array('edit_own_posts_with_cred_' . $form_id => current_user_can('edit_own_posts_with_cred_' . $form_id), 'current_user' => $current_user->ID, 'author' => $mypost->post_author), 'access.log'); cred_log(array('edit_other_posts_with_cred_' . $form_id => current_user_can('edit_other_posts_with_cred_' . $form_id), 'current_user' => $current_user->ID, 'author' => $mypost->post_author), 'access.log'); if (!current_user_can('edit_own_posts_with_cred_' . $form_id) && $current_user->ID == $mypost->post_author) { //$this->error=__('Do not have permission (edit own with this form)','wp-cred'); $this->error = ' '; return; } if (!current_user_can('edit_other_posts_with_cred_' . $form_id) && $current_user->ID != $mypost->post_author) { //$this->error=__('Do not have permission (edit other with this form)','wp-cred'); $this->error = ' '; return; } //cred_log($mypost->post_content); if ($mypost->post_type != $this->_post_type) { $this->error = __('Form type and post type do not match', 'wp-cred'); return; } $myfields = isset($res[1]) ? $res[1] : array(); $mytaxs = isset($res[2]) ? $res[2] : array(); $myextra = isset($res[3]) ? $res[3] : array(); $myfields['post_title'] = array($mypost->post_title); $myfields['post_content'] = array($mypost->post_content); if (isset($mypost->post_excerpt)) { $myfields['post_excerpt'] = array($mypost->post_excerpt); } $this->_post_data = array('fields' => &$myfields, 'post' => &$mypost, 'taxonomies' => &$mytaxs, 'extra' => &$myextra); //cred_log(print_r($mytaxs,true)); //cred_log(print_r($mypost,true)/*.print_r($myfields,true).print_r($myterms,true)*/); //exit; } } } elseif ($this->_form_type == 'new') { cred_log(array('create_posts_with_cred_' . $form_id => current_user_can('create_posts_with_cred_' . $form_id), 'current_user' => $current_user->ID), 'access.log'); if (!current_user_can('create_posts_with_cred_' . $form_id)) { //$this->error=__('Do not have permission (create with this form)','wp-cred'); $this->error = ' '; return; } } $this->_form_content = ''; // set allowed file types $mimes = get_allowed_mime_types(); $this->wp_mimes = array(); foreach ($mimes as $exts => $mime) { $exts_a = explode('|', $exts); foreach ($exts_a as $single_ext) { //$this->form_mimes[$single_ext]=$mime; $this->wp_mimes[] = $single_ext; } } $this->wp_mimes = implode(',', $this->wp_mimes); unset($mimes); $this->_shortcode_parser = CRED_Loader::get('CLASS/Shortcode_Parser', false); }
/** * notifications for the CRED post expiration scheduled task */ function cred_pe_schedule_event_notifications() { if ($this->_post_expiration_enabled) { global $wpdb; /* $posts_for_notifications = $wpdb->get_results( $wpdb->prepare( " SELECT m1.post_id, m1.meta_value AS expiration_time, m2.meta_value AS notifications FROM $wpdb->postmeta m1 INNER JOIN $wpdb->postmeta m2 ON m1.post_id = m2.post_id AND m1.meta_key = %s AND m2.meta_key = %s WHERE m1.meta_value > 0 ", $this->_post_expiration_time_field, $this->_post_expiration_notifications_field ) ); */ $posts_for_notifications = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\tSELECT m1.post_id, m1.meta_value AS expiration_time, m2.meta_value AS notifications\n\t\t\t\t\tFROM {$wpdb->postmeta} m1 INNER JOIN {$wpdb->postmeta} m2\n\t\t\t\t\t\tON m1.post_id = m2.post_id AND m1.meta_key = %s AND m2.meta_key = %s\n\t\t\t\t\tWHERE m1.meta_value IS NOT NULL\n\t\t\t\t", $this->_post_expiration_time_field, $this->_post_expiration_notifications_field)); $now = time(); $posts_ids_for_notifications = array(); foreach ($posts_for_notifications as $post_meta) { $post_meta->notifications = $remaining_notifications = maybe_unserialize($post_meta->notifications); // check wicth notification is to be activated foreach ($post_meta->notifications as $key => $notification) { $notification_time = $post_meta->expiration_time - $notification['event']['expiration_date'] * DAY_IN_SECONDS; if ($notification_time <= $now) { // notify $posts_ids_for_notifications[] = $post_meta->post_id; $form_id = isset($notification['form_id']) ? $notification['form_id'] : NULL; if (isset($notification['to']['author']) && 'author' == $notification['to']['author']) { $_POST['form_' . $form_id . '_referrer_post_id'] = $post_meta->post_id; } // get Notification Manager object CRED_Loader::load('CLASS/Notification_Manager'); // add extra plceholder codes add_filter('cred_subject_notification_codes', array(&$this, 'extraSubjectNotificationCodes'), 5, 3); add_filter('cred_body_notification_codes', array(&$this, 'extraBodyNotificationCodes'), 5, 3); // send notification now CRED_Notification_Manager::sendNotifications($post_meta->post_id, $form_id, array($notification)); // remove extra plceholder codes remove_filter('cred_subject_notification_codes', array(&$this, 'extraSubjectNotificationCodes'), 5, 3); remove_filter('cred_body_notification_codes', array(&$this, 'extraBodyNotificationCodes'), 5, 3); // remove notification from list unset($remaining_notifications[$key]); } } // update notifications list if (empty($remaining_notifications)) { delete_post_meta($post_meta->post_id, $this->_post_expiration_notifications_field); } else { sort($remaining_notifications); update_post_meta($post_meta->post_id, $this->_post_expiration_notifications_field, $remaining_notifications); } } } }
public static function HelpMenuPage() { CRED_Loader::load('VIEW/help'); }
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); }
private function notify($post_id, $attachedData = null) { $form =& $this->_formData; $_fields = $form->getFields(); // init notification manager if needed if (isset($_fields['notification']->enable) && $_fields['notification']->enable && !empty($_fields['notification']->notifications)) { // add extra plceholder codes add_filter('cred_subject_notification_codes', array(&$this, 'extraSubjectNotificationCodes'), 5, 3); add_filter('cred_body_notification_codes', array(&$this, 'extraBodyNotificationCodes'), 5, 3); CRED_Loader::load('CLASS/Notification_Manager'); if ($form->getForm()->post_type == CRED_USER_FORMS_CUSTOM_POST_NAME) { CRED_Notification_Manager::set_user_fields(); } // add the post to notification management CRED_Notification_Manager::add($post_id, $form->getForm()->ID, $_fields['notification']->notifications); // send any notifications now if needed CRED_Notification_Manager::triggerNotifications($post_id, array('event' => 'form_submit', 'form_id' => $form->getForm()->ID, 'notification' => $_fields['notification']), $attachedData); // remove extra plceholder codes remove_filter('cred_subject_notification_codes', array(&$this, 'extraSubjectNotificationCodes'), 5, 3); remove_filter('cred_body_notification_codes', array(&$this, 'extraBodyNotificationCodes'), 5, 3); } }
public static function replaceContentWithForm($content) { global $post, $wp_query; //resolve problem when view templates are added in sidebar widgets remove_filter('the_content', array(__CLASS__, 'replaceContentWithForm'), 1000); // if it is front page and form preview is required if (array_key_exists('cred_form_preview', $_GET)) { CRED_Loader::load('CLASS/Form_Builder'); return CRED_Form_Builder::getForm(intval($_GET['cred_form_preview']), null, true); } if (array_key_exists('cred_user_form_preview', $_GET)) { CRED_Loader::load('CLASS/Form_Builder'); return CRED_Form_Builder::getUserForm(intval($_GET['cred_user_form_preview']), null, true); } global $_creds_created; if (!isset($_creds_created)) { $_creds_created = array(); } if (!empty($_creds_created) && in_array($_GET['cred-edit-form'], $_creds_created)) { return apply_filters('the_content', $content); } if (strpos($content, 'cred-edit-form=' . $_GET['cred-edit-form']) !== false || array_key_exists('cred-edit-form', $_GET) && !is_admin()) { array_push($_creds_created, $_GET['cred-edit-form']); CRED_Loader::load('CLASS/Form_Builder'); // get a localised form if exists return CRED_Form_Builder::getForm(self::getLocalisedID(intval($_GET['cred-edit-form'])), $post->ID, false); } if (array_key_exists('cred-edit-form', $_GET) && !is_admin()) { if (strpos($content, 'cred-edit-form=' . $_GET['cred-edit-form']) !== false) { array_push($_creds_created, $_GET['cred-edit-form']); // Show if the content has a cred-edit-form link. CRED_Loader::load('CLASS/Form_Builder'); // get a localised form if exists return CRED_Form_Builder::getForm(self::getLocalisedID(intval($_GET['cred-edit-form'])), $post->ID, false); } else { // Check if it's called from the_content function or wpv-post-body function. $db = debug_backtrace(); //StaticClass::_pre($db); foreach ($db as $n => $dbf) { if (isset($dbf['function']) && ($dbf['function'] == 'the_content' || $dbf['function'] == 'wpv_shortcode_wpv_post_body') || $dbf['function'] == 'apply_filters' && in_array('the_content', $dbf['args'])) { array_push($_creds_created, $_GET['cred-edit-form']); CRED_Loader::load('CLASS/Form_Builder'); return CRED_Form_Builder::getForm(self::getLocalisedID(intval($_GET['cred-edit-form'])), $post->ID, false); } } // if (isset($db[3]['function']) && ($db[3]['function'] == 'the_content' || $db[3]['function'] == 'wpv_shortcode_wpv_post_body')) { // CRED_Loader::load('CLASS/Form_Builder'); // return CRED_Form_Builder::getForm(self::getLocalisedID(intval($_GET['cred-edit-form'])), $post->ID, false); // } } } // else do nothing return $content; }
public function onOrderChange($data) { // HOOKS API //do_action('cred_commerce_before_send_notifications', $data); // send notifications if (!isset($data['new_status']) || !in_array($data['new_status'], array('pending', 'failed', 'processing', 'completed', 'on-hold', 'cancelled', 'refunded'))) { return; } // not spam with useless notifications ;) if (isset($data['cred_meta']) && $data['cred_meta']) { $model = CREDC_Loader::get('MODEL/Main'); CRED_Loader::load('CLASS/Notification_Manager'); foreach ($data['cred_meta'] as $ii => $meta) { if (!isset($meta['cred_form_id'])) { continue; } $form_id = $meta['cred_form_id']; $form_slug = ''; $cred_form_post = get_post($form_id); if ($cred_form_post) { $form_slug = $cred_form_post->post_name; } $post_id = $meta['cred_post_id']; $form = $model->getForm($form_id, true); if ($form->isCommerce && isset($form->fields['notification'])) { $this->_data = array('order_id' => $data['order_id'], 'previous_status' => $data['previous_status'], 'new_status' => $data['new_status'], 'cred_meta' => $meta); add_filter('cred_custom_notification_event', array(&$this, 'notificationOrderEvent'), 1, 4); CRED_Notification_Manager::triggerNotifications($post_id, array('event' => 'order_modified', 'form_id' => $form_id, 'notification' => $form->fields['notification'])); remove_filter('cred_custom_notification_event', array(&$this, 'notificationOrderEvent'), 1, 4); $this->_data = false; } } } // HOOKS API do_action('cred_commerce_after_send_notifications_form_' . $form_slug, $data); do_action('cred_commerce_after_send_notifications', $data); }
// enable CRED_DEBUG, on top of this file /* cred_log($_SERVER); cred_log(CRED_Loader::getDocRoot()); cred_log(CRED_Loader::getBaseUrl()); cred_log(CRED_PLUGIN_URL); */ // register assets CRED_Loader::add('assets', array('SCRIPT' => array('cred_console_polyfill' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => null, 'path' => CRED_ASSETS_URL . '/common/js/console_polyfill.js', 'src' => CRED_ASSETS_PATH . '/common/js/console_polyfill.js'), 'cred_template_script' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('jquery', 'jquery-ui-sortable', 'jquery-ui-dialog', 'wp-pointer'), 'path' => CRED_ASSETS_URL . '/common/js/gui.js', 'src' => CRED_ASSETS_PATH . '/common/js/gui.js'), 'cred_codemirror_dev' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => null, 'path' => CRED_ASSETS_URL . '/third-party/codemirror.js', 'src' => CRED_ASSETS_PATH . '/third-party/codemirror.js'), 'cred_extra' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('jquery', 'jquery-effects-scale'), 'path' => CRED_ASSETS_URL . '/common/js/extra.js', 'src' => CRED_ASSETS_PATH . '/common/js/extra.js'), 'cred_utils' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('jquery', 'cred_extra'), 'path' => CRED_ASSETS_URL . '/common/js/utils.js', 'src' => CRED_ASSETS_PATH . '/common/js/utils.js'), 'cred_gui' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('jquery', 'jquery-ui-dialog', 'wp-pointer'), 'path' => CRED_ASSETS_URL . '/common/js/gui.js', 'src' => CRED_ASSETS_PATH . '/common/js/gui.js'), 'cred_mvc' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('jquery'), 'path' => CRED_ASSETS_URL . '/common/js/mvc.js', 'src' => CRED_ASSETS_PATH . '/common/js/mvc.js'), 'cred_cred_dev' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('jquery', 'underscore', 'cred_console_polyfill', 'cred_codemirror_dev', 'cred_extra', 'cred_utils', 'cred_gui', 'cred_mvc'), 'path' => CRED_ASSETS_URL . '/js/cred.js', 'src' => CRED_ASSETS_PATH . '/js/cred.js'), 'cred_cred_nocodemirror_dev' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('jquery', 'underscore', 'cred_console_polyfill', 'cred_extra', 'cred_utils', 'cred_gui', 'cred_mvc'), 'path' => CRED_ASSETS_URL . '/js/cred.js', 'src' => CRED_ASSETS_PATH . '/js/cred.js'), 'cred_cred_post_dev' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('jquery', 'cred_console_polyfill', 'cred_extra', 'cred_utils', 'cred_gui'), 'path' => CRED_ASSETS_URL . '/js/post.js', 'src' => CRED_ASSETS_PATH . '/js/post.js'), 'cred_cred_nocodemirror' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('jquery', 'underscore', 'jquery-ui-dialog', 'wp-pointer', 'jquery-effects-scale', 'cred_extra', 'cred_utils', 'cred_gui', 'cred_mvc'), 'path' => CRED_ASSETS_URL . '/js/cred.js', 'src' => CRED_ASSETS_PATH . '/js/cred.js'), 'cred_wizard_dev' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('cred_cred_dev'), 'path' => CRED_ASSETS_URL . '/js/wizard.js', 'src' => CRED_ASSETS_PATH . '/js/wizard.js')), 'STYLE' => array('cred_template_style' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('wp-admin', 'colors-fresh', 'toolset-font-awesome', 'cred_cred_style_nocodemirror_dev'), 'path' => CRED_ASSETS_URL . '/css/gfields.css', 'src' => CRED_ASSETS_PATH . '/css/gfields.css'), 'cred_codemirror_style_dev' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => null, 'path' => CRED_ASSETS_URL . '/third-party/codemirror.css', 'src' => CRED_ASSETS_PATH . '/third-party/codemirror.css'), 'toolset-font-awesome' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => null, 'path' => CRED_ASSETS_URL . '/common/css/font-awesome.min.css', 'src' => CRED_ASSETS_PATH . '/common/css/font-awesome.min.css'), 'cred_cred_style_dev' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('toolset-font-awesome', 'cred_codemirror_style_dev', 'wp-jquery-ui-dialog', 'wp-pointer'), 'path' => CRED_ASSETS_URL . '/css/cred.css', 'src' => CRED_ASSETS_PATH . '/css/cred.css'), 'cred_cred_style_nocodemirror_dev' => array('loader_url' => CRED_FILE_URL, 'loader_path' => CRED_FILE_PATH, 'version' => CRED_FE_VERSION, 'dependencies' => array('toolset-font-awesome', 'wp-jquery-ui-dialog', 'wp-pointer'), 'path' => CRED_ASSETS_URL . '/css/cred.css', 'src' => CRED_ASSETS_PATH . '/css/cred.css')))); // init loader for this specific plugin and load assets if needed CRED_Loader::init(CRED_FILE_PATH); // if called when loading assets, ;) if (!function_exists('add_action')) { return; } /* exit; */ if (defined('ABSPATH')) { // register dependencies CRED_Loader::add('dependencies', array('CONTROLLER' => array('%%PARENT%%' => array(array('class' => 'CRED_Abstract_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Abstract.php')), 'Forms' => array(array('class' => 'CRED_Forms_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Forms.php')), 'Posts' => array(array('class' => 'CRED_Posts_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Posts.php')), 'Settings' => array(array('class' => 'CRED_Settings_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Settings.php')), 'Generic_Fields' => array(array('class' => 'CRED_Generic_Fields_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Generic_Fields.php'))), 'MODEL' => array('%%PARENT%%' => array(array('class' => 'CRED_Abstract_Model', 'path' => CRED_MODELS_PATH . '/Abstract.php')), 'Forms' => array(array('path' => ABSPATH . '/wp-admin/includes/post.php'), array('class' => 'CRED_Forms_Model', 'path' => CRED_MODELS_PATH . '/Forms.php')), 'UserForms' => array(array('path' => ABSPATH . '/wp-admin/includes/post.php'), array('class' => 'CRED_User_Forms_Model', 'path' => CRED_MODELS_PATH . '/UserForms.php')), 'Settings' => array(array('class' => 'CRED_Settings_Model', 'path' => CRED_MODELS_PATH . '/Settings.php')), 'Fields' => array(array('class' => 'CRED_Fields_Model', 'path' => CRED_MODELS_PATH . '/Fields.php')), 'UserFields' => array(array('class' => 'CRED_User_Fields_Model', 'path' => CRED_MODELS_PATH . '/UserFields.php'))), 'TABLE' => array('%%PARENT%%' => array(array('class' => 'WP_List_Table', 'path' => ABSPATH . '/wp-admin/includes/class-wp-list-table.php')), 'EmbeddedForms' => array(array('class' => 'CRED_Forms_List_Table', 'path' => CRED_TABLES_PATH . '/EmbeddedForms.php')), 'Forms' => array(array('class' => 'CRED_Forms_List_Table', 'path' => CRED_TABLES_PATH . '/Forms.php')), 'UserForms' => array(array('class' => 'CRED_Forms_List_Table', 'path' => CRED_TABLES_PATH . '/UserForms.php')), 'Custom_Fields' => array(array('class' => 'CRED_Custom_Fields_List_Table', 'path' => CRED_TABLES_PATH . '/Custom_Fields.php'))), 'CLASS' => array('CRED_Helper' => array(array('class' => 'CRED_Helper', 'path' => CRED_CLASSES_PATH . '/CRED_Helper.php')), 'CRED' => array(array('class' => 'CRED_Admin', 'path' => CRED_ROOT_CLASSES_PATH . '/CRED_Admin.php'), array('class' => 'CRED_Helper', 'path' => CRED_CLASSES_PATH . '/CRED_Helper.php'), array('class' => 'CRED_Router', 'path' => CRED_COMMON_PATH . '/Router.php'), array('class' => 'CRED_CRED', 'path' => CRED_CLASSES_PATH . '/CRED.php'), array('class' => 'CRED_PostExpiration', 'path' => CRED_CLASSES_PATH . '/CredPostExpiration.php')), 'Form_Helper' => array(array('class' => 'CRED_Form_Builder_Helper', 'path' => CRED_CLASSES_PATH . '/Form_Builder_Helper.php')), 'Form_Builder' => array(array('class' => 'CRED_Form_Builder_Helper', 'path' => CRED_CLASSES_PATH . '/Form_Builder_Helper.php'), array('class' => 'CRED_Form_Builder', 'path' => CRED_CLASSES_PATH . '/Form_Builder.php')), 'Form_Translator' => array(array('class' => 'CRED_Form_Translator', 'path' => CRED_CLASSES_PATH . '/Form_Translator.php')), 'XML_Processor' => array(array('class' => 'CRED_XML_Processor', 'path' => CRED_COMMON_PATH . '/XML_Processor.php')), 'Mail_Handler' => array(array('class' => 'CRED_Mail_Handler', 'path' => CRED_COMMON_PATH . '/Mail_Handler.php')), 'Notification_Manager' => array(array('class' => 'CRED_Notification_Manager', 'path' => CRED_CLASSES_PATH . '/Notification_Manager.php')), 'Shortcode_Parser' => array(array('class' => 'CRED_Shortcode_Parser', 'path' => CRED_COMMON_PATH . '/Shortcode_Parser.php')), 'Router' => array(array('class' => 'CRED_Router', 'path' => CRED_COMMON_PATH . '/Router.php'))), 'VIEW' => array('custom_fields' => array(array('path' => CRED_VIEWS_PATH . '/custom_fields.php')), 'forms' => array(array('path' => CRED_VIEWS_PATH . '/forms.php')), 'user_forms' => array(array('path' => CRED_VIEWS_PATH . '/user_forms.php')), 'embedded-forms' => array(array('path' => CRED_VIEWS_PATH . '/embedded-forms.php')), 'settings' => array(array('path' => CRED_VIEWS_PATH . '/settings.php')), 'help' => array(array('path' => CRED_VIEWS_PATH . '/help.php'))), 'TEMPLATE' => array('insert-form-shortcode-button-extra' => array('path' => CRED_TEMPLATES_PATH . '/insert-form-shortcode-button-extra.tpl.php'), 'insert-field-shortcode-button' => array('path' => CRED_TEMPLATES_PATH . '/insert-field-shortcode-button.tpl.php'), 'insert-user-field-shortcode-button' => array('path' => CRED_TEMPLATES_PATH . '/insert-user-field-shortcode-button.tpl.php'), 'insert-generic-field-shortcode-button' => array('path' => CRED_TEMPLATES_PATH . '/insert-generic-field-shortcode-button.tpl.php'), 'scaffold-button' => array('path' => CRED_TEMPLATES_PATH . '/scaffold-button.tpl.php'), 'user-scaffold-button' => array('path' => CRED_TEMPLATES_PATH . '/user-scaffold-button.tpl.php'), 'insert-form-shortcode-button' => array('path' => CRED_TEMPLATES_PATH . '/insert-form-shortcode-button.tpl.php'), 'form-settings-meta-box' => array('path' => CRED_TEMPLATES_PATH . '/form-settings-meta-box.tpl.php'), 'user-form-settings-meta-box' => array('path' => CRED_TEMPLATES_PATH . '/user-form-settings-meta-box.tpl.php'), 'post-type-meta-box' => array('path' => CRED_TEMPLATES_PATH . '/post-type-meta-box.tpl.php'), 'notification-meta-box' => array('path' => CRED_TEMPLATES_PATH . '/notification-meta-box.tpl.php'), 'notification-user-meta-box' => array('path' => CRED_TEMPLATES_PATH . '/notification-user-meta-box.tpl.php'), 'extra-meta-box' => array('path' => CRED_TEMPLATES_PATH . '/extra-meta-box.tpl.php'), 'text-settings-meta-box' => array('path' => CRED_TEMPLATES_PATH . '/text-settings-meta-box.tpl.php'), 'delete-post-link' => array('path' => CRED_TEMPLATES_PATH . '/delete-post-link.tpl.php'), 'generic-field-shortcode-setup' => array('path' => CRED_TEMPLATES_PATH . '/generic-field-shortcode-setup.tpl.php'), 'conditional-shortcode-setup' => array('path' => CRED_TEMPLATES_PATH . '/conditional-shortcode-setup.tpl.php'), 'custom-field-setup' => array('path' => CRED_TEMPLATES_PATH . '/custom-field-setup.tpl.php'), 'notification-condition' => array('path' => CRED_TEMPLATES_PATH . '/notification-condition.tpl.php'), 'notification-subject-codes' => array('path' => CRED_TEMPLATES_PATH . '/notification-subject-codes.tpl.php'), 'notification-user-subject-codes' => array('path' => CRED_TEMPLATES_PATH . '/notification-user-subject-codes.tpl.php'), 'notification-body-codes' => array('path' => CRED_TEMPLATES_PATH . '/notification-body-codes.tpl.php'), 'notification-user-body-codes' => array('path' => CRED_TEMPLATES_PATH . '/notification-user-body-codes.tpl.php'), 'notification' => array('path' => CRED_TEMPLATES_PATH . '/notification.tpl.php'), 'notification-user' => array('path' => CRED_TEMPLATES_PATH . '/notification-user.tpl.php'), 'pe_form_meta_box' => array('path' => CRED_TEMPLATES_PATH . '/pe_form_meta_box.tpl.php'), 'pe_form_notification_option' => array('path' => CRED_TEMPLATES_PATH . '/pe_form_notification_option.tpl.php'), 'pe_post_meta_box' => array('path' => CRED_TEMPLATES_PATH . '/pe_post_meta_box.tpl.php'), 'pe_settings_meta_box' => array('path' => CRED_TEMPLATES_PATH . '/pe_settings_meta_box.tpl.php')))); } require_once "embedded/common/functions.php"; //function cred_auto_load() { // // load basic classes // CRED_Loader::load('CLASS/CRED'); // // init them // CRED_CRED::init(); //} // //add_action('cred_loader_auto_load', 'cred_auto_load', 1); // load basic classes CRED_Loader::load('CLASS/CRED'); // init them CRED_CRED::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( )); */ }