private static function execute($controller = false, $action = false) { global $wp_query; if (!current_user_can(CRED_CAPABILITY) && !isset($_GET['ajax'])) { return; } // process pseudo-admin routes, needs care here to handle check correctly !! if (!$wp_query->query || $wp_query->is_404) { if (!$controller || !$action) { list($controller, $action) = self::processRoute(); if (!$controller || !$action) { return; } // no route to handle } $controllerObject = CRED_Loader::get("CONTROLLER/{$controller}", false); if ($controllerObject) { if (method_exists($controllerObject, $action)) { if (is_callable(array($controllerObject, $action))) { call_user_func_array(array($controllerObject, $action), array($_GET, $_POST)); $wp_query->is_404 = false; } } } } }
public function __construct() { global $wpdb; $this->wpdb = $wpdb; if (class_exists('CRED_Loader', false)) { $this->credmodel = CRED_Loader::get('MODEL/Forms'); } }
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; }
public function removeCustomField($get, $post) { if (isset($get['field_name']) && isset($get['post_type'])) { $field_name = $get['field_name']; $post_type = $get['post_type']; $fm = CRED_Loader::get('MODEL/Fields'); $fm->ignoreCustomFields($post_type, array($field_name), 'reset'); echo 'true'; die; } die; }
public function toggleHighlight($get, $post) { if (isset($post['cred_highlight'])) { $sm = CRED_Loader::get('MODEL/Settings'); $settings = $sm->getSettings(); if ($post['cred_highlight'] == '1') { $settings['syntax_highlight'] = 1; } else { $settings['syntax_highlight'] = 0; } $sm->updateSettings($settings); //echo $post['cred_highlight']; die(0); } }
public function removeCustomField($get, $post) { if (!current_user_can(CRED_CAPABILITY)) { wp_die(); } if (!isset($get['_wpnonce']) || !wp_verify_nonce($get['_wpnonce'], '_cred_customfield')) { echo "wpnonce error"; die; } if (isset($get['field_name']) && isset($get['post_type'])) { $field_name = sanitize_text_field($get['field_name']); $post_type = $get['post_type']; $fm = CRED_Loader::get('MODEL/Fields'); $fm->ignoreCustomFields($post_type, array($field_name), 'reset'); echo 'true'; die; } die; }
public function processAllFormsForStrings() { $fm = CRED_Loader::get('MODEL/Forms'); $forms = $fm->getAllForms(); foreach ($forms as $form) { $this->setFormData($form->ID, $form->post_title); $notification = $fm->getFormCustomField($form->ID, 'notification'); $settings = $fm->getFormCustomField($form->ID, 'form_settings'); $this->processFormForStrings($form->post_content, 'Value: '); // register form title $this->registerString('Form Title: ' . $form->post_title, $form->post_title); if ($settings && isset($settings->message)) { $this->registerString('Display Message: ' . $form->post_title, $settings->message); } // register Notification Data also if ($notification && isset($notification->notifications) && is_array($notification->notifications)) { foreach ($notification->notifications as $ii => $nott) { switch ($nott['mail_to_type']) { case 'wp_user': $this->registerString('CRED Notification ' . $ii . ' Mail To', $nott['mail_to_user']); break; case 'specific_mail': $this->registerString('CRED Notification ' . $ii . ' Mail To', $nott['mail_to_specific']); break; default: break; } $this->registerString('CRED Notification ' . $ii . ' Subject', $nott['subject']); $this->registerString('CRED Notification ' . $ii . ' Body', $nott['body']); } } $extra = $fm->getFormCustomField($form->ID, 'extra'); if ($extra && isset($extra->messages)) { // register messages also foreach ($extra->messages as $msgid => $msg) { $this->registerString('Message_' . $msgid, $msg['msg']); } } } }
public function getUserData($post_id) { if ($post_id && is_numeric($post_id)) { $fm = CRED_Loader::get('MODEL/UserFields'); $fields = $fm->getFields(array()); //$_data = get_user_by("id", $post_id); $_data = get_userdata($post_id); $_nickname = get_user_meta($post_id, 'nickname', true); if (!isset($_nickname) || empty($_nickname)) { return $this->error(__('User does not exist', 'wp-cred')); } $_data->data->nickname = $_nickname; if ($_data) { $data = (array) $_data->data; $myfields = array(); foreach ($fields['form_fields'] as $key => $value) { if ($key == 'user_pass') { continue; } if (isset($data[$key])) { $myfields[$key][] = $data[$key]; } } foreach ($fields['custom_fields'] as $key => $value) { if (!isset($value['meta_key'])) { $myfields[$key][] = ""; continue; } $user_meta = get_user_meta($post_id, $value['meta_key'], !(isset($value['data']['repetitive']) && $value['data']['repetitive'] == 1)); $myfields[$value['meta_key']][] = $user_meta; } $data = (object) $data; $data->post_type = 'user'; return (object) array('post' => $data, 'fields' => $myfields, 'taxonomies' => array(), 'extra' => array()); } return $this->error(__('User does not exist', 'wp-cred')); } return 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; } $settings_model->updateSettings($settings); break; } // CRED_PostExpiration
public static function sendNotifications($post_id, $form_id, $notificationsToSent) { // custom action hooks here, for 3rd-party integration //do_action('cred_before_send_notifications_'.$form_id, $post_id, $form_id, $notificationsToSent); //do_action('cred_before_send_notifications', $post_id, $form_id, $notificationsToSent); // get Mailer $mailer = CRED_Loader::get('CLASS/Mail_Handler'); // get current user $user = self::getCurrentUserData(); $is_user_form = self::get_form_type($form_id) == CRED_USER_FORMS_CUSTOM_POST_NAME; // get Model $model = $is_user_form ? CRED_Loader::get('MODEL/UserForms') : CRED_Loader::get('MODEL/Forms'); //user created/updated $the_user = $is_user_form ? get_userdata($post_id)->data : null; // get some data for placeholders $form_post = get_post($form_id); $form_title = $form_post ? $form_post->post_title : ''; $link = get_permalink($post_id); $title = get_the_title($post_id); $admin_edit_link = CRED_CRED::getPostAdminEditLink($post_id); //get_edit_post_link( $post_id ); //$date=date('d/m/Y H:i:s'); $date = date('Y-m-d H:i:s', current_time('timestamp')); // placeholder codes, allow to add custom $data_subject = apply_filters('cred_subject_notification_codes', array('%%USER_USERID%%' => isset($the_user) && isset($the_user->ID) ? $the_user->ID : '', '%%USER_EMAIL%%' => isset($the_user) && isset($the_user->user_email) ? $the_user->user_email : '', '%%USER_USERNAME%%' => isset(StaticClass::$_username_generated) ? StaticClass::$_username_generated : '', '%%USER_PASSWORD%%' => isset(StaticClass::$_password_generated) ? StaticClass::$_password_generated : '', '%%USER_NICKNAME%%' => isset(StaticClass::$_nickname_generated) ? StaticClass::$_nickname_generated : '', '%%USER_LOGIN_NAME%%' => $user->login, '%%USER_DISPLAY_NAME%%' => $user->display_name, '%%POST_ID%%' => $post_id, '%%POST_TITLE%%' => $title, '%%FORM_NAME%%' => $form_title, '%%DATE_TIME%%' => $date), $form_id, $post_id); // placeholder codes, allow to add custom $data_body = apply_filters('cred_body_notification_codes', array('%%USER_USERID%%' => isset($the_user) && isset($the_user->ID) ? $the_user->ID : '', '%%USER_EMAIL%%' => isset($the_user) && isset($the_user->user_email) ? $the_user->user_email : '', '%%USER_USERNAME%%' => isset(StaticClass::$_username_generated) ? StaticClass::$_username_generated : '', '%%USER_PASSWORD%%' => isset(StaticClass::$_password_generated) ? StaticClass::$_password_generated : '', '%%USER_NICKNAME%%' => isset(StaticClass::$_nickname_generated) ? StaticClass::$_nickname_generated : '', '%%USER_LOGIN_NAME%%' => $user->login, '%%USER_DISPLAY_NAME%%' => $user->display_name, '%%POST_ID%%' => $post_id, '%%POST_TITLE%%' => $title, '%%POST_LINK%%' => $link, '%%POST_ADMIN_LINK%%' => $admin_edit_link, '%%FORM_NAME%%' => $form_title, '%%DATE_TIME%%' => $date), $form_id, $post_id); //cred_log(array($post_id, $form_id, $data_subject, $data_body, $notificationsToSent)); foreach ($notificationsToSent as $notification) { // bypass if nothing if (!$notification || empty($notification) || !(isset($notification['to']['type']) || isset($notification['to']['author']))) { continue; } // reset mail handler $mailer->reset(); $mailer->setHTML(true, false); $recipients = array(); if (isset($notification['to']['author']) && 'author' == $notification['to']['author']) { $author_post_id = isset($_POST['form_' . $form_id . '_referrer_post_id']) ? $_POST['form_' . $form_id . '_referrer_post_id'] : 0; if (0 == $author_post_id && $post_id) { $mypost = get_post($post_id); $author_id = $mypost->post_author; } else { $mypost = get_post($author_post_id); $author_id = $user->ID; if (!isset($author_id)) { $author_id = $mypost->post_author; } } if ($author_id) { $_to_type = 'to'; $user_info = get_userdata($author_id); $_addr_name = isset($user_info) && isset($user_info->user_firstname) && !empty($user_info->user_firstname) ? $user_info->user_firstname : false; $_addr_lastname = isset($user_info) && isset($user_info->user_lasttname) && !empty($user_info->user_lasttname) ? $user_info->user_lastname : false; $_addr = $user_info->user_email; if (isset($_addr)) { $recipients[] = array('to' => $_to_type, 'address' => $_addr, 'name' => $_addr_name, 'lastname' => $_addr_lastname); } } } // parse Notification Fields if (!isset($notification['to']['type'])) { $notification['to']['type'] = array(); } if (!is_array($notification['to']['type'])) { $notification['to']['type'] = (array) $notification['to']['type']; } // notification to a mail field (which is saved as post meta) if (in_array('mail_field', $notification['to']['type']) && isset($notification['to']['mail_field']['address_field']) && !empty($notification['to']['mail_field']['address_field'])) { $_to_type = 'to'; $_addr = false; $_addr_name = false; $_addr_lastname = false; if ($is_user_form) { $_addr = $the_user->user_email; } else { $_addr = $model->getPostMeta($post_id, $notification['to']['mail_field']['address_field']); } if (isset($notification['to']['mail_field']['to_type']) && in_array($notification['to']['mail_field']['to_type'], array('to', 'cc', 'bcc'))) { $_to_type = $notification['to']['mail_field']['to_type']; } if (isset($notification['to']['mail_field']['name_field']) && !empty($notification['to']['mail_field']['name_field']) && '###none###' != $notification['to']['mail_field']['name_field']) { $_addr_name = $is_user_form ? $model->getUserMeta($post_id, $notification['to']['mail_field']['name_field']) : $model->getPostMeta($post_id, $notification['to']['mail_field']['name_field']); } if (isset($notification['to']['mail_field']['lastname_field']) && !empty($notification['to']['mail_field']['lastname_field']) && '###none###' != $notification['to']['mail_field']['lastname_field']) { $_addr_lastname = $is_user_form ? $model->getUserMeta($post_id, $notification['to']['mail_field']['lastname_field']) : $model->getPostMeta($post_id, $notification['to']['mail_field']['lastname_field']); } // add to recipients $recipients[] = array('to' => $_to_type, 'address' => $_addr, 'name' => $_addr_name, 'lastname' => $_addr_lastname); } // notification to an exisiting wp user if (in_array('wp_user', $notification['to']['type'])) { $_to_type = 'to'; $_addr = false; $_addr_name = false; $_addr_lastname = false; if (isset($notification['to']['wp_user']['to_type']) && in_array($notification['to']['wp_user']['to_type'], array('to', 'cc', 'bcc'))) { $_to_type = $notification['to']['wp_user']['to_type']; } $_addr = $notification['to']['wp_user']['user']; $user_id = email_exists($_addr); if ($user_id) { $user_info = get_userdata($user_id); $_addr_name = isset($user_info->user_firstname) && !empty($user_info->user_firstname) ? $user_info->user_firstname : false; $_addr_lastname = isset($user_info->user_lasttname) && !empty($user_info->user_lasttname) ? $user_info->user_lastname : false; // add to recipients $recipients[] = array('to' => $_to_type, 'address' => $_addr, 'name' => $_addr_name, 'lastname' => $_addr_lastname); } } // notification to an exisiting wp user if (in_array('user_id_field', $notification['to']['type'])) { $_to_type = 'to'; $_addr = false; $_addr_name = false; $_addr_lastname = false; if (isset($notification['to']['user_id_field']['to_type']) && in_array($notification['to']['user_id_field']['to_type'], array('to', 'cc', 'bcc'))) { $_to_type = $notification['to']['user_id_field']['to_type']; } //$user_id = $is_user_form ? @trim($model->getUserMeta($post_id, $notification['to']['user_id_field']['field_name'])) : @trim($model->getPostMeta($post_id, $notification['to']['user_id_field']['field_name'])); $user_id = $is_user_form ? $post_id : @trim($model->getPostMeta($post_id, $notification['to']['user_id_field']['field_name'])); if ($user_id) { $user_info = get_userdata($user_id); if ($user_info) { $_addr = isset($user_info->user_email) && !empty($user_info->user_email) ? $user_info->user_email : false; $_addr_name = isset($user_info->user_firstname) && !empty($user_info->user_firstname) ? $user_info->user_firstname : false; $_addr_lastname = isset($user_info->user_lasttname) && !empty($user_info->user_lasttname) ? $user_info->user_lastname : false; // add to recipients $recipients[] = array('to' => $_to_type, 'address' => $_addr, 'name' => $_addr_name, 'lastname' => $_addr_lastname); } } } // notification to specific recipients if (in_array('specific_mail', $notification['to']['type']) && isset($notification['to']['specific_mail']['address'])) { $tmp = explode(',', $notification['to']['specific_mail']['address']); foreach ($tmp as $aa) { $recipients[] = array('address' => $aa, 'to' => false, 'name' => false, 'lastname' => false); } unset($tmp); } // add custom recipients by 3rd-party //cred_log(array('cred_notification_recipients', $recipients, $notification, $form_id, $post_id)); //$recipients=apply_filters('cred_notification_recipients', $recipients, array('form_id'=>$form_id, 'post_id'=>$post_id, 'notification'=>$notification)); $recipients = apply_filters('cred_notification_recipients', $recipients, $notification, $form_id, $post_id); if (!$recipients || empty($recipients)) { continue; } // build recipients foreach ($recipients as $ii => $recipient) { // nowhere to send, bypass if (!isset($recipient['address']) || !$recipient['address']) { unset($recipients[$ii]); continue; } if (false === $recipient['to']) { // this is already formatted $recipients[$ii] = $recipient['address']; continue; } $tmp = ''; $tmp .= $recipient['to'] . ': '; $tmp2 = array(); if ($recipient['name']) { $tmp2[] = $recipient['name']; } if ($recipient['lastname']) { $tmp2[] = $recipient['lastname']; } if (!empty($tmp2)) { $tmp .= implode(' ', $tmp2) . ' <' . $recipient['address'] . '>'; } else { $tmp .= $recipient['address']; } $recipients[$ii] = $tmp; } //cred_log($recipients); $mailer->addRecipients($recipients); if (isset($_POST[StaticClass::PREFIX . 'cred_container_id'])) { $notification['mail']['body'] = str_replace("[cred-container-id]", StaticClass::$_cred_container_id, $notification['mail']['body']); } global $current_user_id; $current_user_id = $user_id; if (!$user_id && $is_user_form) { $current_user_id = $post_id; } // build SUBJECT $_subj = ''; if (isset($notification['mail']['subject'])) { $_subj = $notification['mail']['subject']; } // build BODY $_bod = ''; if (isset($notification['mail']['body'])) { $_bod = $notification['mail']['body']; } // replace placeholders $_subj = self::replacePlaceholders($_subj, $data_subject); // replace placeholders $_bod = self::replacePlaceholders($_bod, $data_body); //fixing https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188538611/comments if (defined('WPCF_EMBEDDED_ABSPATH') && WPCF_EMBEDDED_ABSPATH) { require_once WPCF_EMBEDDED_ABSPATH . '/frontend.php'; } // provide WPML localisation if (isset($notification['_cred_icl_string_id']['subject'])) { $notification_subject_string_translation_name = self::getNotification_translation_name($notification['_cred_icl_string_id']['subject']); if ($notification_subject_string_translation_name) { $_subj = cred_translate($notification_subject_string_translation_name, $_subj, 'cred-form-' . $form_title . '-' . $form_id); } } // provide WPML localisation if (isset($notification['_cred_icl_string_id']['body'])) { $notification_body_string_translation_name = self::getNotification_translation_name($notification['_cred_icl_string_id']['body']); if ($notification_body_string_translation_name) { $_bod = cred_translate($notification_body_string_translation_name, $_bod, 'cred-form-' . $form_title . '-' . $form_id); } } // parse shortcodes if necessary relative to $post_id $_subj = CRED_Helper::renderWithPost(stripslashes($_subj), $post_id, false); $mailer->setSubject($_subj); // parse shortcodes/rich text if necessary relative to $post_id $_bod = CRED_Helper::renderWithPost($_bod, $post_id); //https://icanlocalize.basecamphq.com/projects/11629195-toolset-peripheral-work/todo_items/195775787/comments#310779109 $_bod = stripslashes($_bod); $mailer->setBody($_bod); // build FROM address / name, independantly $_from = array(); if (isset($notification['from']['address']) && !empty($notification['from']['address'])) { $_from['address'] = $notification['from']['address']; } if (isset($notification['from']['name']) && !empty($notification['from']['name'])) { $_from['name'] = $notification['from']['name']; } if (!empty($_from)) { $mailer->setFrom($_from); } // send it $_send_result = $mailer->send(); if ($_send_result !== true) { update_option('_' . $form_id . '_last_mail_error', $_send_result); } } // custom action hooks here, for 3rd-party integration //do_action('cred_after_send_notifications_'.$form_id, $post_id); //do_action('cred_after_send_notifications', $post_id); }
function glue_get_original_field_list() { //original fields $orig_fields = "post_title,post_content,post_excerpt"; $taxonomies = get_taxonomies(); $exclude = array('nav_menu', 'link_category', 'post_format'); $taxonomies = array_diff($taxonomies, $exclude); sort($taxonomies, SORT_STRING); foreach ($taxonomies as $taxonomy) { $orig_fields .= ',' . $taxonomy; } $fm = CRED_Loader::get('MODEL/Fields'); $custom_fields = $fm->getPostTypeCustomFields('post', array(), false, 1); foreach ($custom_fields as $custom_field) { $orig_fields .= ',' . $custom_field; } return $orig_fields; }
/** * getUserFields * @param type $get * @param type $post */ public function getUserFields($get, $post) { if (!current_user_can(CRED_CAPABILITY)) { wp_die(); } if (!isset($post['_wpnonce']) || !wp_verify_nonce($post['_wpnonce'], '_cred_wpnonce')) { echo "wpnonce error"; die; } $autogenerate = array('username' => isset($post['ag_uname']) ? $post['ag_uname'] : 1, 'nickname' => isset($post['ag_nname']) ? $post['ag_nname'] : 1, 'password' => isset($post['ag_pass']) ? $post['ag_pass'] : 1); $role = isset($post['role']) ? $post['role'] : ""; $fields_model = CRED_Loader::get('MODEL/UserFields'); $fields_all = $fields_model->getFields($autogenerate, $role); $settings_model = CRED_Loader::get('MODEL/Settings'); $settings = $settings_model->getSettings(); $publickey = $settings['recaptcha']['public_key']; $privatekey = $settings['recaptcha']['private_key']; $fields_all['extra_fields']['recaptcha']['public_key'] = $publickey; $fields_all['extra_fields']['recaptcha']['private_key'] = $privatekey; echo json_encode($fields_all); die; }
public static function remove_meta_box($id, $screen, $context) { //global $wp_meta_boxes; if (empty($screen)) { $screen = get_current_screen(); } elseif (is_string($screen)) { $screen = convert_to_screen($screen); } $page = $screen->id; if (!isset(self::$metaboxes)) { self::$metaboxes = array(); } if (!isset(self::$metaboxes[$page])) { self::$metaboxes[$page] = array(); } if (!isset(self::$metaboxes[$page][$context])) { self::$metaboxes[$page][$context] = array(); } foreach (array('high', 'core', 'default', 'low') as $priority) { self::$metaboxes[$page][$context][$priority][$id] = false; } }
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 function deletePost($get, $post) { global $current_user; if (!array_key_exists('_wpnonce', $get) || !array_key_exists('cred_link_id', $get) || !array_key_exists('cred_action', $get) || !wp_verify_nonce($get['_wpnonce'], $get['cred_link_id'] . '_' . $get['cred_action'])) { die('Security check'); } $jsfuncs = array(); if (array_key_exists('cred_link_id', $_GET)) { $jsfuncs['parent._cred_cred_delete_post_handler'] = array('"' . $_GET['cred_link_id'] . '"'); } if (!isset($get['cred_post_id'])) { //echo json_encode(false); $jsfuncs['alert'] = array('"' . __('No post defined', 'wp-cred') . '"'); echo $this->renderJsFunction($jsfuncs); die; } $post_id = intval($get['cred_post_id']); $post = get_post($post_id); if ($post) { if (!current_user_can('delete_own_posts_with_cred') && $current_user->ID == $post->post_author) { die('<strong>' . __('Do not have permission (own)', 'wp-cred') . '</strong>'); } if (!current_user_can('delete_other_posts_with_cred') && $current_user->ID != $post->post_author) { die('<strong>' . __('Do not have permission (other)', 'wp-cred') . '</strong>'); } $fm = CRED_Loader::get('MODEL/Forms'); if ($get['cred_action'] == 'delete') { $result = $fm->deletePost($post_id, true); } elseif ($get['cred_action'] == 'trash') { $result = $fm->deletePost($post_id, false); } else { die; } //echo json_encode($result); if ($result) { $jsfuncs['alert'] = array('"' . __('Post deleted', 'wp-cred') . '"'); } else { $jsfuncs['alert'] = array('"' . __('Post delete failed', 'wp-cred') . '"'); } } echo $this->renderJsFunction($jsfuncs); die; }
public static function addMessagesMetaBox2($form, $args) { $extra = $args['args']['extra']; if (isset($extra->messages)) { $messages = $extra->messages; } else { $messages = false; } $model = CRED_Loader::get('MODEL/UserForms'); if (!$messages) { $messages = $model->getDefaultMessages(); } echo CRED_Loader::tpl('text-settings-meta-box', array('messages' => $messages, 'descriptions' => $model->getDefaultMessageDescriptions())); }
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 static function init($deps = false) { // init dependencies paths, if any self::$__dependencies__ = array(self::_CONTROLLER_ => array(self::_PREFIX_ => CRED_NAME . '_', self::_SUFFIX_ => '_Controller', self::_PARENT_ => array('class' => 'CRED_Abstract_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Abstract_Controller.php'), 'Forms' => array(array('class' => 'CRED_Forms_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Forms_Controller.php')), 'Posts' => array(array('class' => 'CRED_Posts_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Posts_Controller.php')), 'Settings' => array(array('class' => 'CRED_Settings_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Settings_Controller.php')), 'Generic_Fields' => array(array('class' => 'CRED_Generic_Fields_Controller', 'path' => CRED_CONTROLLERS_PATH . '/Generic_Fields_Controller.php'))), self::_MODEL_ => array(self::_PREFIX_ => CRED_NAME . '_', self::_SUFFIX_ => '_Model', self::_PARENT_ => array('class' => 'CRED_Abstract_Model', 'path' => CRED_MODELS_PATH . '/Abstract_Model.php'), 'Forms' => array(array('class' => 'CRED_Forms_Model', 'path' => CRED_MODELS_PATH . '/Forms_Model.php')), 'Settings' => array(array('class' => 'CRED_Settings_Model', 'path' => CRED_MODELS_PATH . '/Settings_Model.php')), 'Fields' => array(array('class' => 'CRED_Fields_Model', 'path' => CRED_MODELS_PATH . '/Fields_Model.php'))), self::_LIST_TABLE_ => array(self::_PREFIX_ => CRED_NAME . '_', self::_SUFFIX_ => '_List_Table', self::_PARENT_ => array('class' => 'WP_List_Table', 'path' => ABSPATH . '/wp-admin/includes/class-wp-list-table.php'), 'Forms' => array(array('class' => 'CRED_Forms_List_Table', 'path' => CRED_TABLES_PATH . '/Forms_List_Table.php')), 'Custom_Fields' => array(array('class' => 'CRED_Custom_Fields_List_Table', 'path' => CRED_TABLES_PATH . '/Custom_Fields_List_Table.php'))), self::_CLASS_ => array(self::_PREFIX_ => CRED_NAME . '_', self::_SUFFIX_ => '', 'CRED' => array(array('class' => 'CRED_CRED', 'path' => CRED_CLASSES_PATH . '/CRED.php')), 'Form_Builder' => array(array('class' => 'CRED_Form_Builder', 'path' => CRED_CLASSES_PATH . '/Form_Builder.php')), 'Form_Processor' => array(array('class' => 'CRED_Form_Processor', 'path' => CRED_CLASSES_PATH . '/Form_Processor.php')), 'XML_Processor' => array(array('class' => 'CRED_XML_Processor', 'path' => CRED_CLASSES_PATH . '/XML_Processor.php')), 'Mail_Handler' => array(array('class' => 'CRED_Mail_Handler', 'path' => CRED_CLASSES_PATH . '/Mail_Handler.php')), 'Shortcode_Parser' => array(array('class' => 'CRED_Shortcode_Parser', 'path' => CRED_CLASSES_PATH . '/Shortcode_Parser.php')), 'Router' => array(array('class' => 'CRED_Router', 'path' => CRED_CLASSES_PATH . '/Router.php')), 'Ajax_Router' => array(array('class' => 'CRED_Ajax_Router', 'path' => CRED_CLASSES_PATH . '/Ajax_Router.php'))), self::_THIRDPARTY_ => array(self::_PREFIX_ => '', self::_SUFFIX_ => '', 'MyZebra_Form' => array(array('class' => 'MyZebra_Form', 'path' => CRED_THIRDPARTY_PATH . '/zebra_form/MyZebra_Form.php')), 'MyZebra_Parser' => array(array('class' => 'MyZebra_Parser', 'path' => CRED_THIRDPARTY_PATH . '/zebra_form/MyZebra_Parser.php'))), self::_VIEW_ => array(self::_PREFIX_ => '', self::_SUFFIX_ => '', 'custom_fields' => array(array('path' => CRED_VIEWS_PATH . '/custom_fields.php')), 'forms' => array(array('path' => CRED_VIEWS_PATH . '/forms.php')), 'settings' => array(array('path' => CRED_VIEWS_PATH . '/settings.php')), 'help' => array(array('path' => CRED_VIEWS_PATH . '/help.php')))); }
public function deletePost($get, $post) { global $current_user; /* $return_codes=array( '101'=>'Success', '202'=>'Failure', '404'=>'No post' '505'=>'No permision', ); */ if (!array_key_exists('_wpnonce', $get) || !array_key_exists('_cred_link_id', $get) || !array_key_exists('cred_action', $get) || !wp_verify_nonce($get['_wpnonce'], $get['_cred_link_id'] . '_' . $get['cred_action'])) { die('Security check'); } $jsfuncs = array(); $redirect_url = false; if (!isset($get['cred_post_id'])) { //echo json_encode(false); //$jsfuncs['alert']=array("'".esc_js(__('No post defined','wp-cred'))."'"); $jsfuncs['parent._cred_cred_delete_post_handler'] = array('false', '""', '""', '404'); echo $this->renderJsFunction($jsfuncs); die; } $post_id = intval($get['cred_post_id']); $post = get_post($post_id); if ($post) { if (!current_user_can('delete_own_posts_with_cred') && $current_user->ID == $post->post_author) { $jsfuncs['parent._cred_cred_delete_post_handler'] = array('false', '""', '""', '505'); echo $this->renderJsFunction($jsfuncs); die; //die('<strong>'.__('Do not have permission (own)','wp-cred').'</strong>'); } if (!current_user_can('delete_other_posts_with_cred') && $current_user->ID != $post->post_author) { $jsfuncs['parent._cred_cred_delete_post_handler'] = array('false', '""', '""', '505'); echo $this->renderJsFunction($jsfuncs); die; //die('<strong>'.__('Do not have permission (other)','wp-cred').'</strong>'); } $action = apply_filters('cred_delete_action', $get['cred_action'], $post_id); $result = false; $redirect_url = false; if ($action && in_array($action, array('delete', 'trash'))) { if (array_key_exists('_cred_url', $get) && !empty($get['_cred_url'])) { $redirect_url = urldecode($get['_cred_url']); } if ($redirect_url) { $redirect_url = apply_filters('cred_redirect_after_delete_action', $redirect_url, $post_id); } if ($redirect_url) { $redirect_url = '"' . $redirect_url . '"'; } else { $redirect_url = 'false'; } $fm = CRED_Loader::get('MODEL/Forms'); if ($get['cred_action'] == 'delete') { $result = $fm->deletePost($post_id, true); } elseif ($get['cred_action'] == 'trash') { $result = $fm->deletePost($post_id, false); } else { $jsfuncs['parent._cred_cred_delete_post_handler'] = array('false', '""', '""', '505'); echo $this->renderJsFunction($jsfuncs); die; } } //echo json_encode($result); // //Added redirect to page_id //https://icanlocalize.basecamphq.com/projects/11629195-toolset-peripheral-work/todo_items/195364093/comments#307203773 if (isset($get['redirect']) && $get['redirect'] != 0 && is_numeric($get['redirect'])) { $p = get_post($get['redirect']); if ($p) { $redirect_url = '"' . get_permalink($p->ID) . '"'; } } //############################################### if ($result) { if (array_key_exists('_cred_link_id', $get)) { $jsfuncs['parent._cred_cred_delete_post_handler'] = array('false', '"' . urldecode($get['_cred_link_id']) . '"', $redirect_url, '101'); } else { $jsfuncs['parent._cred_cred_delete_post_handler'] = array('false', '""', $redirect_url, '101'); } //$jsfuncs['alert']=array("'".esc_js(__('Post deleted','wp-cred'))."'"); } else { if (array_key_exists('_cred_link_id', $get)) { $jsfuncs['parent._cred_cred_delete_post_handler'] = array('false', '"' . urldecode($get['_cred_link_id']) . '"', $redirect_url, '202'); } else { $jsfuncs['parent._cred_cred_delete_post_handler'] = array('false', '""', $redirect_url, '202'); } //$jsfuncs['alert']=array("'".esc_js(__('Post delete failed','wp-cred'))."'"); } } echo $this->renderJsFunction($jsfuncs); die; }
/** * Render CRED Form notification option for post expiration. * */ public function cred_pe_add_notification_option($form, $options, $notification) { if ($form->post_type == CRED_USER_FORMS_CUSTOM_POST_NAME) { return; } list($ii, $name, $type) = $options; $notification = self::array_merge_distinct(array('event' => array('expiration_date' => 0)), $notification); echo CRED_Loader::tpl('pe_form_notification_option', array('cred_post_expiration' => $this, 'notification' => $notification, 'ii' => $ii, 'name' => $name, 'type' => $type)); }
public function processAllForms() { $fm = CRED_Loader::get('MODEL/Forms'); $forms = $fm->getAllForms(); foreach ($forms as $form) { $data = array('post' => $form, 'message' => '', 'messages' => array(), 'notification' => (object) array('enable' => 0, 'notifications' => array())); $fields = $fm->getFormCustomFields($form->ID, array('form_settings', 'notification', 'extra')); $settings = isset($fields['form_settings']) ? $fields['form_settings'] : false; $notification = isset($fields['notification']) ? $fields['notification'] : false; $extra = isset($fields['extra']) ? $fields['extra'] : false; // register settings if ($settings && isset($settings->form['action_message'])) { $data['message'] = $settings->form['action_message']; } // register Notification Data also if ($notification) { $data['notification'] = $notification; } // register extra fields if ($extra && isset($extra->messages)) { // register messages also $data['messages'] = $extra->messages; } $this->processForm($data); } }
function cred_embedded_html() { if (isset($_GET['cred_id']) && is_numeric($_GET['cred_id'])) { $cred_id = (int) $_GET['cred_id']; //$cred = get_post($cred_id); $cred = get_post($cred_id, OBJECT, 'edit'); //StaticClass::_pre($cred); if (null == $cred) { wp_die('<div class="wpv-setting-container"><p class="toolset-alert toolset-alert-error">' . __('You attempted to edit a CRED that doesn’t exist. Perhaps it was deleted?', 'wpv-views') . '</p></div>'); } elseif ('cred-form' != $cred->post_type) { wp_die('<div class="wpv-setting-container"><p class="toolset-alert toolset-alert-error">' . __('You attempted to edit a CRED that doesn’t exist. Perhaps it was deleted?', 'wpv-views') . '</p></div>'); } else { CRED_Loader::loadAsset('STYLE/cred_codemirror_style_dev', 'cred_codemirror_style', false, CRED_CONCAT_ASSETS); wp_enqueue_style('cred_codemirror_style'); CRED_Loader::loadAsset('SCRIPT/cred_codemirror_dev', 'cred_codemirror_dev', false, CRED_CONCAT_ASSETS); wp_enqueue_script('cred_codemirror_dev'); $sm = CRED_Loader::get('MODEL/Settings'); $settings = $sm->getSettings(); $fm = CRED_Loader::get('MODEL/Forms'); $form_fields = $fm->getFormCustomFields($cred_id, array('form_settings', 'notification', 'extra', 'wizard')); $forms_model = CRED_Loader::get('MODEL/Forms'); $settings = $forms_model->getFormCustomField($cred_id, 'form_settings'); $fields_model = CRED_Loader::get('MODEL/Fields'); $fields_all = $fields_model->getFields($cred->post_type); if ($settings->post['post_status'] == 'trash') { wp_die('<div class="wpv-setting-container"><p class="toolset-alert toolset-alert-error">' . __("You can\\'t edit this CRED because it is in the Trash. Please restore it and try again.", 'wpv-views') . '</p></div>'); } $_button_getcred = '<a style="vertical-align: baseline; background: none repeat scroll 0 0 #f6921e; border-color: #ef6223; box-shadow: 0 1px 0 rgba(239, 239, 239, 0.5) inset, 0 1px 0 rgba(0, 0, 0, 0.15); color: #fff; text-decoration: none;" class="button button-primary-toolset" title="get cred" target="_blank" href="http://wp-types.com/home/cred/?utm_source=credplugin&utm_campaign=cred&utm_medium=embedded-cred-promotional-link&utm_term=Get CRED">Get CRED</a>'; $_header = "You are viewing the read-only version of this CRED form. To edit it, you need to get CRED plugin. {$_button_getcred}"; $_content = "CRED lets you build forms for editing any WordPress content on the site’s front-end. You can choose if the form creates or edits content and the type of content it will create or edit. The form is designed with simple HTML and shortcodes."; $settings_post_type = $settings->post['post_type']; $settings_post_status = $settings->post['post_status']; $settings_type = $settings->form['type']; $settings_action = $settings->form['action']; $has_captcha = $settings->form['include_captcha_scaffold'] == 1 ? " and includes captcha field " : ""; $notification = $form_fields['notification']; if ($notification->enable == 1 && count($notification->notifications) > 0) { $notification_txt = "<p>Enabled</p>"; foreach ($notification->notifications as $n => $notf) { if (count($notf['to']['type']) > 0) { $notification_txt .= "A notification will be sent to "; //StaticClass::_pre($notf['to']['type']); foreach ($notf['to']['type'] as $m => $t) { if ($t == 'wp_user' || $t == 'mail_field' || $t == 'user_id_field') { continue; } $notification_txt .= "<b>" . normalize_notf_txt($t) . "</b>"; } foreach ($notf['to']['wp_user'] as $a => $b) { if ($b != 'to') { $notification_txt .= " <b>" . normalize_notf_txt($b) . "</b> "; } } } if (isset($notf['event']) && !empty($notf['event'])) { $notification_event = "<p>The notification event is set to <b>" . trans_notf_event($notf['event']['type']) . "</b></p>"; $post_status_event = "<p>The notification post status event is set to <b>" . trans_notf_event($notf['event']['post_status']) . "</b></p>"; $condition_event = ""; if (!empty($notf['event']['condition']) && count($notf['event']['condition']) > 0) { $condition_event = "<p>The notification is <b>Based to conditions</b></p>"; } $notification_txt .= " {$notification_event} {$post_status_event} {$condition_event} "; } if (isset($notf['to']['author']) && $notf['to']['author'] == 'author') { $notification_txt .= "<p>A notification will be <b>Sent to the Author</b></p>"; } } } else { $notification_txt = "Disabled"; } $settings_txt = "This Form "; switch ($settings_type) { case 'new': $act = "Creates"; $settings_txt .= '<b>Creates Content</b>'; break; case 'edit': $act = "Edits"; $settings_txt .= '<b>Edits Content</b>'; break; } $settings_txt .= " and after submition "; switch ($settings_action) { case 'form': $settings_txt .= '<b>keeps displaying this form</b>'; break; case 'message': $settings_txt .= '<b>displays a custom message</b>'; break; case 'post': $settings_txt .= '<b>displays a post</b>'; break; case 'page': $settings_txt .= '<b>got to a custom page</b>'; break; } $settings_txt .= $settings->form['hide_comments'] == 1 ? "<p>Comments are hidden</p>" : ""; $settings_post_txt = "This Form {$act} <b>{$settings_post_type}</b> and the status will be <b>" . trans_txt($settings_post_status) . "</b>" . $has_captcha; $extra = $form_fields['extra']; $css = $extra->css; $css_txt = ""; $js = $extra->js; $css_txt = "Empty"; if (!empty($css)) { $css_txt = $css; } $js_txt = "Empty"; if (!empty($js)) { $js_txt = $js; } ?> <div style="clear:both;height:20px;"></div> <h2><?php echo $cred->post_title; ?> </h2> <div style="width:950px;height:auto;"> <div class="toolset-help js-info-box"> <div class="toolset-help-content"> <h2 style="color: #222; font-size: 1.1em; font-weight:bold; margin: 0.83em 0;"><?php echo $_header; ?> </h2> <p><?php echo $_content; ?> </p> </div> <div class="toolset-help-sidebar"> <div class="toolset-help-sidebar-ico"></div> </div> </div> </div> <h3>Form Settings:</h3> <?php echo $settings_txt; ?> <h3>Post Type Settings:</h3> <?php echo $settings_post_txt; ?> <h3>Form Content:</h3> <div style="width:950px;height:auto;"> <textarea id="mycontent"><?php echo $cred->post_content; ?> </textarea> </div> <script> jQuery(document).ready(function () { CodeMirror.defineMode("myshortcodes", codemirror_shortcodes_overlay); CodeMirror.fromTextArea(document.getElementById("mycontent") , { mode: 'myshortcodes', //"text/html", tabMode: "indent", lineWrapping: true, lineNumbers: true, readOnly: "nocursor" }); }); </script> <?php if (false) { ?> <div style="padding:5px;margin-left:10px;border:1px #000 solid;width:80%;height:200px;overflow-y:auto;"><?php echo $cred->post_content; ?> </div><?php } ?> <?php if (false) { ?> <h3>JS:</h3> <?php echo $js_txt; ?> <h3>CSS:</h3> <?php echo $css_txt; ?> <?php } ?> <h3>Notification:</h3> <?php echo $notification_txt; ?> <?php //StaticClass::_pre($form_fields['extra']); //StaticClass::_pre($cred); //StaticClass::_pre($settings); //StaticClass::_pre($fields_all); } } else { wp_die('<div class="wpv-setting-container"><p class="toolset-alert toolset-alert-error">' . __('You attempted to edit a View that doesn’t exist. Perhaps it was deleted?', 'wpv-views') . '</p></div>'); } ?> <?php }
/** * method forms the data output style * */ function display_rows() { $path = admin_url('admin.php') . '?page=CRED_Fields'; $setfieldpath = cred_route('/Generic_Fields/getCustomField'); $editfieldpath = cred_route('/Generic_Fields/getCustomField'); $removefieldpath = cred_route('/Generic_Fields/removeCustomField'); //Get the records registered in the prepare_items method $records = $this->items; $cred_fields = CRED_Loader::get('MODEL/Fields')->getCustomFields($this->_post_type); $default_types = CRED_Loader::get('MODEL/Fields')->getTypesDefaultFields(true); //Get the columns registered in the get_columns and get_sortable_columns methods list($columns, $hidden) = $this->get_column_info(); //Loop for each record if (empty($records)) { return false; } foreach ($records as $rec) { //Open the line $field_id = $rec; $ignore = false; $credfieldtype = __('Not Set', 'wp-cred'); $credfieldname = __('Not Set', 'wp-cred'); if (isset($cred_fields[$rec])) { $credfieldtype = $cred_fields[$rec]['type']; $credfieldname = isset($default_types[$cred_fields[$rec]['type']]) ? $default_types[$cred_fields[$rec]['type']]['title'] : $credfieldname; if (isset($cred_fields[$rec]['_cred_ignore'])) { $ignore = true; } } //if ($ignore) // echo '<tr id="'.$field_id.'" class="cred-ignore-field">'; //else echo '<tr id="' . $field_id . '">'; //$checkbox_id = "checkbox_" . $field_id; //$checkbox = "<input type='checkbox' name='checked[]' value='" . $field_id . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $rec . "</label>"; /*$ignorecheckbox_id = "ignorecheckbox_" . $field_id; $unignorecheckbox_id = "unignorecheckbox_" . $ignorecheckbox_id; if ($ignore) $ignorecheckbox = "<input checked='checked' type='checkbox' name='ignorechecked[]' value='" . $field_id . "' id='" . $ignorecheckbox_id . "' /><label style='margin-left:10px;' for='" . $ignorecheckbox_id . "' >" . __('Not include in Scaffold','wp-cred') . "</label>"; else $ignorecheckbox = "<input type='checkbox' name='ignorechecked[]' value='" . $field_id . "' id='" . $ignorecheckbox_id . "' /><label style='margin-left:10px;' for='" . $ignorecheckbox_id . "' >" . __('Not include in Scaffold','wp-cred') . "</label>"; $unignorecheckbox = "<input style='display:none;' type='checkbox' name='unignorechecked[]' value='" . $field_id . "' id='" . $unignorecheckbox_id . "' />"; $resetcheckbox_id = "resetcheckbox_" . $field_id; $resetcheckbox = "<input type='checkbox' name='resetchecked[]' value='" . $field_id . "' id='" . $resetcheckbox_id . "' /><label style='margin-left:10px;' for='" . $resetcheckbox_id . "' >" . __('Reset CRED settings','wp-cred') . "</label>"; */ foreach ($columns as $column_name => $column_display_name) { //Style attributes for each col $class = "class='{$column_name} column-{$column_name}'"; $style = ""; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = $class . $style; //Display the cell switch ($column_name) { /*case "cb": echo "<th scope='row' class='check-column'>$checkbox</th>"; break;*/ case "col_field_name": //$actions = array(); //$actions['edit'] = '<a class="submitedit thickbox" href="'.$editfieldpath.'&post_type='.$this->_post_type.'&field_name='.$rec.'&TB_iframe=true&width=600&height=450" title="'.__('Edit','wp-cred').'">'.__('Edit','wp-cred').'</a>'; echo '<td ' . $attributes . '><strong><a class="thickbox" href="' . $editfieldpath . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '&TB_iframe=true&width=600&height=450" title="" title="' . __('Edit', 'wp-cred') . '">' . stripslashes($rec) . '</a>'; //echo $this->row_actions( $actions ); echo '</td>'; break; /*case "col_post_type": echo '<td '.$attributes.'>'.$this->_post_type.'</td>'; break;*/ /*case "col_post_type": echo '<td '.$attributes.'>'.$this->_post_type.'</td>'; break;*/ case "col_cred_type": echo '<td ' . $attributes . '><span class="cred-field-type" style="margin-right:15px">' . $credfieldname . '</span></td>'; break; case "col_actions": $actions = array('<a style="margin-right:10px" class="cred-field-actions _cred-field-set thickbox" href="' . $setfieldpath . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '&TB_iframe=true&width=600&height=450" title="' . __('Set field type', 'wp-cred') . '">' . __('Add', 'wp-cred') . '</a>', '<a style="margin-right:10px" class="cred-field-actions _cred-field-edit thickbox" href="' . $editfieldpath . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '&TB_iframe=true&width=600&height=450" title="' . __('Edit field settings', 'wp-cred') . '">' . __('Edit', 'wp-cred') . '</a>', '<a style="margin-right:10px" class="cred-field-actions _cred-field-remove" href="' . $removefieldpath . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '" title="' . __('Remove this field as a CRED field type', 'wp-cred') . '">' . __('Remove', 'wp-cred') . '</a>'); $act_out = implode('', $actions); //.'<br />'.$unignorecheckbox.$ignorecheckbox.'<br />'.$resetcheckbox; echo '<td ' . $attributes . '>' . $act_out . '</td>'; break; } } echo '</tr>'; } }
/** * Filter the_content tag * Added support for resolving third party shortcodes in cred shortcodes */ function cred_do_shortcode($content) { $shortcodeParser = CRED_Loader::get('CLASS/Shortcode_Parser'); $content = $shortcodeParser->parse_content_shortcodes($content); return $content; }
private function setAllowed(&$allowed_tags, &$allowed_protocols) { $__allowed_tags = wp_kses_allowed_html('post'); $__allowed_protocols = array('http', 'https', 'mailto'); $settings_model = CRED_Loader::get('MODEL/Settings'); $settings = $settings_model->getSettings(); $allowed_tags = isset($settings['allowed_tags']) ? $settings['allowed_tags'] : $__allowed_tags; foreach ($__allowed_tags as $key => $value) { if (!isset($allowed_tags[$key])) { unset($__allowed_tags[$key]); } } $allowed_tags = $__allowed_tags; $allowed_protocols = $__allowed_protocols; }
/** * cred_create_form * * you can create dinamically a cred form * * @param type $name * @param type $mode [new|edit] * @param type $post_type * return $post_id if created */ public static function cred_create_form($name, $mode, $post_type) { $name = sanitize_text_field($name); if (empty(self::$_created) && !in_array($name, self::$_created)) { self::$_created[] = $name; $form = get_page_by_title(html_entity_decode($name), OBJECT, CRED_FORMS_CUSTOM_POST_NAME); if (isset($form) && isset($form->ID)) { //TODO: give message? CRED form already exists return; } $model = CRED_Loader::get('MODEL/Forms'); $fields_model = CRED_Loader::get('MODEL/Fields'); $fields_all = $fields_model->getFields($post_type); $form_id = 1; $form_name = $name; $includeWPML = false; $nlcnt = 0; $groups = array(); $groups_out = ""; foreach ($fields_all['groups'] as $f => $fields) { $nlcnt++; $groups[$f] = $fields; $fields = explode(",", $fields); $groups_out .= self::groupOutput($f, $fields, $fields_all['groups_conditions'], $fields_all['custom_fields'], $form_id, $form_name, $includeWPML, PAD) . NL; } $taxs_out = ''; if (isset($fields_all['taxonomies_count']) && intval($fields_all['taxonomies_count']) > 0) { foreach ($fields_all['taxonomies'] as $f => $taxonomy) { $tax = self::array2Obj($taxonomy); if ($tax->type == 'taxonomy_hierarchical') { $tmp = array('master_taxonomy' => $tax->name, 'name' => $tax->name . '_add_new', 'add_new_taxonomy' => true); $tax->aux = self::array2Obj($tmp); } else { $tmp = array('master_taxonomy' => $tax->name, 'name' => $tax->name . '_popular', 'popular' => true); $tax->aux = self::array2Obj($tmp); } $taxs_out .= self::taxOutput($tax, $form_id, $form_name, $includeWPML, '') . NL; } } $parents_out = ''; if (isset($fields_all['parents_count']) && intval($fields_all['parents_count']) > 0) { foreach ($fields_all['parents'] as $f => $parent) { $parents_out .= self::fieldOutput($parent, $form_id, $form_name, $includeWPML, '', array('date', 'desc', 0, false, 'No Parent', '-- Select ' . $parent['data']['post_type'] . ' --', $parent['data']['post_type'] . ' must be selected')) . NL; } } // add fields $out = ''; //TODO: check _credModel.get('[form][theme]') how to reproduce in PHP if ('minimal' == 'minimal') { // bypass script and other styles added to form, minimal $out .= '[credform class="cred-form cred-keep-original"]' . NL . NL; } else { $out .= '[credform class="cred-form"]' . NL . NL; } $out .= PAD . self::shortcode($fields_all['form_fields']['form_messages']) . NL . NL; $out .= self::fieldOutput($fields_all['post_fields']['post_title'], $form_id, $form_name, $includeWPML, PAD) . NL . NL; if ($fields_all['post_fields']['post_content']['supports']) { $out .= self::fieldOutput($fields_all['post_fields']['post_content'], $form_id, $form_name, $includeWPML, PAD) . NL . NL; } if ($fields_all['post_fields']['post_excerpt']['supports']) { $out .= self::fieldOutput($fields_all['post_fields']['post_excerpt'], $form_id, $form_name, $includeWPML, PAD) . NL . NL; } if ($fields_all['extra_fields']['_featured_image']['supports']) { $out .= self::fieldOutput($fields_all['extra_fields']['_featured_image'], $form_id, $form_name, $includeWPML, PAD) . NL . NL; } /* out+= self::groupOutputContent('all', $fields_all['_post_data.singular_name+' Properties', groups_out+taxs_out+parents_out, PAD)+NL+NL; */ $out .= $groups_out; if (intval($fields_all['taxonomies_count']) > 0) { $out .= self::groupOutputContent('taxonomies', 'Taxonomies', $taxs_out, PAD) . NL . NL; } if (intval($fields_all['parents_count']) > 0) { $out .= self::groupOutputContent('parents', 'Parents', $parents_out, PAD) . NL . NL; } // if ($('#cred_include_captcha_scaffold').is(':checked')) { // if ($fields_all['extra_fields['recaptcha']['private_key'] != '' && $fields_all['extra_fields['recaptcha']['public_key'] != '') // $out .= PAD + '<div class="cred-field cred-field-recaptcha">' + self::shortcode($fields_all['extra_fields['recaptcha']) + '</div>' . NL . NL; // else { // $('#cred_include_captcha_scaffold').attr("checked", false); // alert('Captcha keys are empty !'); // } // } $out .= PAD . self::shortcode($fields_all['form_fields']['form_submit']) . NL . NL; $out .= '[/credform]' . NL; $form = new stdClass(); $form->ID = ''; $form->post_title = $name; $form->post_content = $out; $form->post_status = 'private'; $form->comment_status = 'closed'; $form->ping_status = 'closed'; $form->post_type = CRED_FORMS_CUSTOM_POST_NAME; $form->post_name = CRED_FORMS_CUSTOM_POST_NAME; //$form->guid=admin_url('admin.php').'?post_type='.CRED_FORMS_CUSTOM_POST_NAME; $fields = array(); $fields['form_settings'] = new stdClass(); $fields['form_settings']->form_type = $mode; $fields['form_settings']->form_action = 'form'; $fields['form_settings']->form_action_page = ''; $fields['form_settings']->redirect_delay = 0; $fields['form_settings']->message = ''; $fields['form_settings']->hide_comments = 1; $fields['form_settings']->include_captcha_scaffold = 0; $fields['form_settings']->include_wpml_scaffold = 0; $fields['form_settings']->has_media_button = 0; $fields['form_settings']->post_type = $post_type; $fields['form_settings']->post_status = 'publish'; $fields['form_settings']->cred_theme_css = 'minimal'; $fields['wizard'] = -1; $fields['extra'] = new stdClass(); $fields['extra']->css = ''; $fields['extra']->js = ''; $fields['extra']->messages = $model->getDefaultMessages(); return $model->saveForm($form, $fields); } }
public function cred_field_shortcodes($atts) { extract(shortcode_atts(array('post' => '', 'field' => '', 'value' => null, 'placeholder' => null, 'escape' => 'false', 'readonly' => 'false', 'taxonomy' => null, 'single_select' => null, 'type' => null, 'display' => null, 'max_width' => null, 'max_height' => null, 'max_results' => null, 'order' => null, 'ordering' => null, 'required' => 'false', 'no_parent_text' => __('No Parent', 'wp-cred'), 'select_text' => __('-- Please Select --', 'wp-cred'), 'validate_text' => $this->getLocalisedMessage('field_required')), $atts)); // make boolean $escape = false; //(bool)(strtoupper($escape)==='TRUE'); // make boolean $readonly = (bool) (strtoupper($readonly) === 'TRUE'); if (!$taxonomy) { if (in_array($field, array_keys($this->_fields['post_fields']))) { if ($post != $this->_post_type) { return ''; } $field = $this->_fields['post_fields'][$field]; $name = $name_orig = $field['slug']; if (isset($field['plugin_type_prefix'])) { $name = $field['plugin_type_prefix'] . $name; } if ($field['type'] == 'image' || $field['type'] == 'file') { $ids = $this->translate_field($name, $field, array('preset_value' => $value, 'is_tax' => false, 'max_width' => $max_width, 'max_height' => $max_height)); } else { $ids = $this->translate_field($name, $field, array('preset_value' => $value, 'value_escape' => $escape, 'make_readonly' => $readonly, 'placeholder' => $placeholder)); } // check which fields are actually used in form $this->_form_fields[$name_orig] = $ids; $this->_form_fields_qualia[$name_orig] = array('type' => $field['type'], 'repetitive' => isset($field['data']['repetitive']) && $field['data']['repetitive'], 'plugin_type' => isset($field['plugin_type']) ? $field['plugin_type'] : '', 'name' => $name); $out = ''; foreach ($ids as $id) { $out .= "[render-cred-field post='{$post}' field='{$id}']"; } return $out; } elseif (in_array($field, array_keys($this->_fields['parents']))) { $name = $name_orig = $field; $field = $this->_fields['parents'][$field]; $potential_parents = CRED_Loader::get('MODEL/Fields')->getPotentialParents($field['data']['post_type'], $this->_post_id, $max_results, $order, $ordering); $field['data']['options'] = array(); $default_option = ''; // enable setting parent form url param if (array_key_exists('parent_' . $field['data']['post_type'] . '_id', $_GET)) { $default_option = $_GET['parent_' . $field['data']['post_type'] . '_id']; } $required = (bool) (strtoupper($required) === 'TRUE'); if (!$required) { $field['data']['options']['-1'] = array('title' => $no_parent_text, 'value' => '-1', 'display_value' => '-1'); } else { $field['data']['options']['-1'] = array('title' => $select_text, 'value' => '', 'display_value' => '', 'dummy' => true); $field['data']['validate'] = array('required' => array('message' => $validate_text, 'active' => 1)); } foreach ($potential_parents as $ii => $option) { $option_id = (string) $option->ID; $field['data']['options'][$option_id] = array('title' => $option->post_title, 'value' => $option_id, 'display_value' => $option_id); } $field['data']['options']['default'] = $default_option; //print_r($field['data']); $ids = $this->translate_field($name, $field, array('preset_value' => $value)); // check which fields are actually used in form $this->_form_fields[$name_orig] = $ids; $this->_form_fields_qualia[$name_orig] = array('type' => $field['type'], 'repetitive' => isset($field['data']['repetitive']) && $field['data']['repetitive'], 'plugin_type' => isset($field['plugin_type']) ? $field['plugin_type'] : '', 'name' => $name); $out = ''; foreach ($ids as $id) { $out .= "[render-cred-field field='{$id}']"; } return $out; } elseif (in_array($field, array_keys($this->_fields['form_fields']))) { $name = $name_orig = $field; $field = $this->_fields['form_fields'][$field]; $ids = $this->translate_field($name, $field, array('preset_value' => $value)); // check which fields are actually used in form $this->_form_fields[$name_orig] = $ids; $this->_form_fields_qualia[$name_orig] = array('type' => $field['type'], 'repetitive' => isset($field['data']['repetitive']) && $field['data']['repetitive'], 'plugin_type' => isset($field['plugin_type']) ? $field['plugin_type'] : '', 'name' => $name); $out = ''; foreach ($ids as $id) { $out .= "[render-cred-field field='{$id}']"; } return $out; } elseif (in_array($field, array_keys($this->_fields['extra_fields']))) { $field = $this->_fields['extra_fields'][$field]; $name = $name_orig = $field['slug']; $ids = $this->translate_field($name, $field, array('preset_value' => $value)); // check which fields are actually used in form $this->_form_fields[$name_orig] = $ids; $this->_form_fields_qualia[$name_orig] = array('type' => $field['type'], 'repetitive' => isset($field['data']['repetitive']) && $field['data']['repetitive'], 'plugin_type' => isset($field['plugin_type']) ? $field['plugin_type'] : '', 'name' => $name); $out = ''; foreach ($ids as $id) { $out .= "[render-cred-field field='{$id}']"; } return $out; } elseif (in_array($field, array_keys($this->_fields['taxonomies']))) { $field = $this->_fields['taxonomies'][$field]; $name = $name_orig = $field['name']; $single_select = $single_select === 'true'; $ids = $this->translate_field($name, $field, array('preset_value' => $display, 'is_tax' => true, 'single_select' => $single_select)); // check which fields are actually used in form $this->_form_fields[$name_orig] = $ids; $this->_form_fields_qualia[$name_orig] = array('type' => $field['type'], 'repetitive' => isset($field['data']['repetitive']) && $field['data']['repetitive'], 'plugin_type' => isset($field['plugin_type']) ? $field['plugin_type'] : '', 'name' => $name); $out = ''; foreach ($ids as $id) { $out .= "[render-cred-field field='{$id}']"; } return $out; } } else { if (in_array($taxonomy, array_keys($this->_fields['taxonomies'])) && in_array($type, array('show_popular', 'add_new'))) { if ($type == 'show_popular' && !$this->_fields['taxonomies'][$taxonomy]['hierarchical'] || $type == 'add_new' && $this->_fields['taxonomies'][$taxonomy]['hierarchical']) { $field = array('taxonomy' => $this->_fields['taxonomies'][$taxonomy], 'type' => $type, 'master_taxonomy' => $taxonomy); $name = $name_orig = $taxonomy . '_' . $type; $ids = $this->translate_field($name, $field, array('preset_value' => $value, 'is_tax' => true)); // check which fields are actually used in form //$this->_form_fields[$name_orig]=$ids; $out = ''; foreach ($ids as $id) { $out .= "[render-cred-field field='{$id}']"; } return $out; } } } return ''; }
public static function add_screen_options() { $screen = get_current_screen(); // get out of here if we are not on our settings page if (!is_array(self::$screens) || !in_array($screen->id . '.php', self::$screens)) { return; } /*$value=$screen->get_option('per_page','default'); if (null===$value) $value=10;*/ $value = 10; if (isset($_REQUEST['wp_screen_options'])) { if (isset($_REQUEST['wp_screen_options']['option']) && 'cred_per_page' == $_REQUEST['wp_screen_options']['option'] && isset($_REQUEST['wp_screen_options']['value'])) { $value = intval($_REQUEST['wp_screen_options']['value']); } } elseif (isset($_REQUEST['per_page'])) { $value = intval($_REQUEST['per_page']); } $args = array('label' => __('Per Page', 'wp-cred'), 'default' => $value, 'option' => 'cred_per_page'); add_screen_option('per_page', $args); // instantiate table now to take care of column options switch ($screen->id) { case CRED_VIEWS_PATH2 . '/forms': CRED_Loader::get('TABLE/Forms'); break; case CRED_VIEWS_PATH2 . '/custom_fields': CRED_Loader::get('TABLE/Custom_Fields'); break; } }
if (!defined('ABSPATH')) { die('Security check'); } // field options $options = array('hidden' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'password' => array('has_default_value' => false, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => "<input type='text' name='default' value='' />"), 'text' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'textfield' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'colorpicker' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => "<input type='text' name='default' value='' />"), 'embed' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => "<input type='text' name='default' value='' />"), 'numeric' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'integer' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'file' => array('has_default_value' => false, 'additional' => '', 'default_selector' => '', 'value_label' => '', 'value_field' => ''), 'video' => array('has_default_value' => false, 'additional' => '', 'default_selector' => '', 'value_label' => '', 'value_field' => ''), 'audio' => array('has_default_value' => false, 'additional' => '', 'default_selector' => '', 'value_label' => '', 'value_field' => ''), 'image' => array('has_default_value' => false, 'additional' => array("<input type='text' size='5' value='' name='field[additional_options][max_width]' /><span style='vertical-align:bottom;margin-left:10px'>" . __('Max. Width', 'wp-cred') . "</span>", "<input type='text' size='5' value='' name='field[additional_options][max_height]' /><span style='vertical-align:bottom;margin-left:10px'>" . __('Max. Height', 'wp-cred') . "</span>"), 'default_selector' => '', 'value_label' => '', 'value_field' => ''), 'checkbox' => array('has_default_value' => true, 'additional' => "<label class='cred-label'><input type='checkbox' class='cred-checkbox' value='1' name='field[additional_options][checked]' /><span style='vertical-align:bottom;margin-left:10px'>" . __('Checked by default', 'wp-cred') . "</span></label>", 'default_selector' => '', 'value_label' => __('Set value:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'select' => array('has_default_value' => true, 'additional' => '', 'default_selector' => "<label class='cred-label'><input type='radio' value='1' class='cred-radio' name='field[options][option_default]' /><span class='cred-radio-replace'></span><span style='vertical-align:bottom;margin-left:10px'>" . __('Default', 'wp-cred') . "</span></label>", 'default_selector_checked' => "<label class='cred-label'><input type='radio' value='1' class='cred-radio' name='field[options][option_default]' checked='checked' /><span class='cred-radio-replace'></span><span style='vertical-align:bottom;margin-left:10px'>" . __('Default', 'wp-cred') . "</span></label>", 'value_label' => '', 'value_field' => ''), 'radio' => array('has_default_value' => true, 'additional' => '', 'default_selector' => "<label class='cred-label'><input type='radio' value='1' class='cred-radio' name='field[options][option_default]' /><span class='cred-radio-replace'></span><span style='vertical-align:bottom;margin-left:10px'>" . __('Default', 'wp-cred') . "</span></label>", 'default_selector_checked' => "<label class='cred-label'><input type='radio' value='1' class='cred-radio' name='field[options][option_default]' checked='checked' /><span class='cred-radio-replace'></span><span style='vertical-align:bottom;margin-left:10px'>" . __('Default', 'wp-cred') . "</span></label>", 'value_label' => '', 'value_field' => ''), 'checkboxes' => array('has_default_value' => true, 'additional' => '', 'default_selector' => "<label class='cred-label'><input type='checkbox' value='1' class='cred-checkbox' name='field[options][option_default][]' /><span style='vertical-align:bottom;margin-left:10px'>" . __('Checked', 'wp-cred') . "</span></label>", 'default_selector_checked' => "<label class='cred-label'><input type='checkbox' value='1' class='cred-checkbox' name='field[options][option_default][]' checked='checked' /><span style='vertical-align:bottom;margin-left:10px'>" . __('Checked', 'wp-cred') . "</span></label>", 'value_label' => '', 'value_field' => ''), 'skype' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default Skypename:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'email' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default email:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'url' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default URL:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'phone' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default phone:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<input type='text' name='field[default]' value='" . $data['default'] . "' />" : "<input type='text' name='field[default]' value='' />"), 'textarea' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<textarea rows='10' style='overflow-y:auto;width:300px;' name='field[default]'>" . $data['default'] . "</textarea>" : "<textarea rows='10' style='overflow-y:auto;width:300px;' name='field[default]'></textarea>"), 'wysiwyg' => array('has_default_value' => true, 'additional' => '', 'default_selector' => '', 'value_label' => __('Default value:', 'wp-cred'), 'value_field' => isset($data['default']) ? "<textarea rows='10' style='overflow-y:auto;width:300px;' name='field[default]'>" . $data['default'] . "</textarea>" : "<textarea rows='10' style='overflow-y:auto;width:300px;' name='field[default]'></textarea>"), 'date' => array('has_default_value' => false, 'additional' => '', 'default_selector' => '', 'value_label' => '', 'value_field' => '')); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <?php // include jquery from wp-admin and styles CRED_Loader::loadAsset('STYLE/cred_template_style', 'cred_template_style', true); wp_print_styles('cred_template_style'); CRED_Loader::loadAsset('SCRIPT/cred_template_script', 'cred_template_script', true); //wp_enqueue_script('jquery-ui-sortable'); wp_print_scripts('cred_template_script'); wp_register_style('onthego-admin-styles', ON_THE_GO_SYSTEMS_BRANDING_REL_PATH . 'onthego-styles/onthego-styles.css'); wp_print_styles('onthego-admin-styles'); ?> <!-- templates --> <script id='option-template' type='text/html-template'> <li class='sub-row sortable-item'> <span class='cell'> <a class='move-option' href='javascript:;' title='<?php echo esc_attr(__('Move option', 'wp-cred')); ?> '></a> <a class='remove-option' href='javascript:;' title='<?php echo esc_attr(__('Remove option', 'wp-cred'));
if (!current_user_can(CRED_CAPABILITY)) { die('Access Denied'); } // include needed files $wp_list_table = CRED_Loader::get('TABLE/UserForms'); $doaction = $wp_list_table->current_action(); $url = CRED_CRED::getNewUserFormLink(); $form_id = ''; $form_name = ''; $form_type = ''; $post_type = ''; $form_content = ''; $fields = ''; // Handle Table Action if ($doaction) { $forms_model = CRED_Loader::get('MODEL/UserForms'); switch ($doaction) { case 'delete-selected': if (isset($_REQUEST['checked']) && is_array($_REQUEST['checked'])) { if (check_admin_referer('cred-bulk-selected-action', 'cred-bulk-selected-field')) { foreach ($_REQUEST['checked'] as $form_id) { $forms_model->deleteForm((int) $form_id); } } } break; case 'clone-selected': if (isset($_REQUEST['checked']) && is_array($_REQUEST['checked'])) { if (check_admin_referer('cred-bulk-selected-action', 'cred-bulk-selected-field')) { foreach ($_REQUEST['checked'] as $form_id) { $forms_model->cloneForm((int) $form_id);