public static function addMenuItems() { $menu_label = CRED_NAME; //__( 'CRED','wp-cred' ); $url = CRED_CRED::getNewFormLink(false); //'post-new.php?post_type='.CRED_FORMS_CUSTOM_POST_NAME; $cf_url = CRED_CRED::getNewUserFormLink(false); //'post-new.php?post_type='.CRED_FORMS_CUSTOM_POST_NAME; $cred_index = 'CRED_Forms'; //CRED_VIEWS_PATH2.'/forms.php'; add_menu_page($menu_label, $menu_label, CRED_CAPABILITY, $cred_index, array(__CLASS__, 'FormsMenuPage'), 'none'); // allow 3rd-party menu items to be included do_action('cred_admin_menu_top', $cred_index); add_submenu_page($cred_index, __('Post Forms', 'wp-cred'), __('Post Forms', 'wp-cred'), CRED_CAPABILITY, 'CRED_Forms', array(__CLASS__, 'FormsMenuPage')); add_submenu_page($cred_index, __('New Post Form', 'wp-cred'), __('New Post Form', 'wp-cred'), CRED_CAPABILITY, $url); // CredUserForms add_submenu_page($cred_index, __('User Forms', 'wp-cred'), __('User Forms', 'wp-cred'), CRED_CAPABILITY, 'CRED_User_Forms', array(__CLASS__, 'UserFormsMenuPage')); add_submenu_page($cred_index, __('New User Form', 'wp-cred'), __('New User Form', 'wp-cred'), CRED_CAPABILITY, $cf_url); // allow 3rd-party menu items to be included do_action('cred_admin_menu_after_forms', $cred_index); add_submenu_page($cred_index, __('Custom Fields', 'wp-cred'), __('Custom Fields', 'wp-cred'), CRED_CAPABILITY, 'CRED_Fields', array(__CLASS__, 'FieldsMenuPage')); // allow 3rd-party menu items to be included do_action('cred_admin_menu_after_fields', $cred_index); add_submenu_page($cred_index, __('Settings/Import', 'wp-cred'), __('Settings/Import', 'wp-cred'), CRED_CAPABILITY, 'CRED_Settings', array(__CLASS__, 'SettingsMenuPage')); // allow 3rd-party menu items to be included do_action('cred_admin_menu_after_settings', $cred_index); $hook = add_submenu_page($cred_index, __('Help', 'wp-cred'), __('Help', 'wp-cred'), CRED_CAPABILITY, 'CRED_Help', array(__CLASS__, 'HelpMenuPage')); add_submenu_page($hook, __('Debug information', 'wp-cred'), __('Debug information', 'wp-cred'), CRED_CAPABILITY, 'cred-debug-information', array(__CLASS__, 'DebugMenuPage')); // allow 3rd-party menu items to be included do_action('cred_admin_menu_bottom', $cred_index); CRED_Helper::$screens = array('toplevel_page_CRED_Forms', 'toplevel_page_CRED_User_Forms', 'cred_page_CRED_Forms', 'cred_page_CRED_User_Forms', 'cred_page_CRED_Fields'); foreach (CRED_Helper::$screens as $screen) { add_action("load-" . $screen, array(__CLASS__, 'addScreenOptions')); } }
public function getCustomField($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; } $popup_close = 'false'; $fm = CRED_Loader::get('MODEL/Fields'); $fields = $fm->getTypesDefaultFields(true); if (isset($post['field']) && is_array($post['field'])) { $fm = CRED_Loader::get('MODEL/Fields'); $fm->setCustomField($post['field']); $popup_close = 'true'; } if (isset($get['field_name'])) { $field_name = sanitize_text_field($get['field_name']); $post_type = isset($get['post_type']) ? $get['post_type'] : 'post'; if (isset($get['_reset_']) && '1' == $get['_reset_']) { $fm->ignoreCustomFields($post_type, array($field_name), 'reset'); $popup_close = 'true'; $data = array(); $field_type = ''; //__('Not Set','wp-cred'); } else { $data = $fm->getCustomField($post_type, $field_name); if (isset($get['field'])) { $field_type = $get['field']; if (isset($data['type']) && $data['type'] != $field_type) { $data = array(); } } else { $field_type = isset($data['type']) ? $data['type'] : 'textfield'; } } echo CRED_Loader::tpl('custom-field-setup', array('field' => $fields[$field_type], 'data' => $data, 'popup_close' => $popup_close, 'field_name' => $field_name, 'post_type' => $post_type, 'url' => CRED_CRED::route('/Generic_Fields/getCustomField?post_type=' . $post_type . '&field_name=' . $field_name . '&_wpnonce=' . wp_create_nonce('_cred_customfield')), 'fields' => $fields)); } die; }
public static function initAdmin() { global $wp_version, $post; // add plugin menus // setup js, css assets CRED_Admin_Helper::setupAdmin(); CRED_CRED::media(); CRED_CRED::setFormsAndButtons(); //TODO: removing before release this new cred embedded version //http://wp.localhost:8080/wp-admin/admin.php?page=cred-embedded&cred_id=601 @add_action('admin_menu', array(CRED_CRED, 'admin_menu'), 20); //WATCHOUT: remove custom meta boxes from cred forms (to avoid any problems) // add custom meta boxes for cred forms add_action('add_meta_boxes_' . CRED_FORMS_CUSTOM_POST_NAME, array(__CLASS__, 'addMetaBoxes'), 20, 1); add_action('add_meta_boxes_' . CRED_USER_FORMS_CUSTOM_POST_NAME, array(__CLASS__, 'addMetaBoxes2'), 20, 1); // save custom fields of cred forms add_action('save_post', array(__CLASS__, 'saveFormCustomFields'), 10, 2); // IMPORTANT: drafts should now be left with post_status=draft, maybe show up because of previous versions add_filter('wp_insert_post_data', array(__CLASS__, 'forcePrivateforForms')); // Remove the Distraction Free Writing button from CRED editors add_filter('wp_editor_expand', array(__CLASS__, 'disable_wp_editor_expand_for_cred_forms'), 99, 2); }
<?php if (!defined('ABSPATH')) { die('Security check'); } if (!current_user_can(CRED_CAPABILITY)) { die('Access Denied'); } // include needed files $wp_list_table = CRED_Loader::get('TABLE/EmbeddedForms'); $doaction = $wp_list_table->current_action(); $url = CRED_CRED::getNewFormLink(); $form_id = ''; $form_name = ''; $form_type = ''; $post_type = ''; $form_content = ''; $fields = ''; // Handle Table Action if ($doaction) { $forms_model = CRED_Loader::get('MODEL/Forms'); $redurl = "?page=" . $_REQUEST['page']; if (headers_sent()) { //die("Redirect failed. Please click on this link: <a href=...>"); echo "<script language='javascript'>window.location='{$redurl}';</script>"; die; } else { exit(wp_redirect("?page=" . $_REQUEST['page'])); } //exit(); }
public static function importCommerceForm($results, $form_id, $data) { if (isset($data['meta']) && isset($data['meta']['commerce'])) { $model = CREDC_Loader::get('MODEL/Main'); $cdata = $data['meta']['commerce']; //cred_log($data); if (isset($cdata['product'])) { $product = self::$handler->getAbsoluteProduct($cdata['product']); if (!$product && isset($results['errors'])) { $results['errors'][] = sprintf(__('Product %s does not exist on this site. You will need to set the CRED Commerce settings for <a href="%s">form %s</a> manually.', 'wp-cred-pay'), $cdata['product'], CRED_CRED::getFormEditLink($form_id), $form_id); } $cdata['product'] = $product; } $model->updateFormCustomField($form_id, 'commerce', $cdata); } return $results; }
function has_cred_form() { return CRED_CRED::has_form(); }
/* 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();
function is_cred_embedded() { return CRED_CRED::is_embedded(); }
/** * method forms the data output style * */ function display_rows() { $path = admin_url('admin.php') . '?page=CRED_Fields'; //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 = '<strong>' . __('Not Set', 'wp-cred') . '</strong>'; $credfieldname = '<strong>' . __('Not Set', 'wp-cred') . '</strong>'; 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; } } // set api ajax paths $setfieldpath = CRED_CRED::route('/Generic_Fields/getCustomField' . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '&_wpnonce=' . wp_create_nonce('_cred_customfield') . '&TB_iframe=true&width=600&height=450'); $editfieldpath = CRED_CRED::route('/Generic_Fields/getCustomField' . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '&_wpnonce=' . wp_create_nonce('_cred_customfield') . '&TB_iframe=true&width=600&height=450'); $removefieldpath = CRED_CRED::route('/Generic_Fields/removeCustomField' . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '&_wpnonce=' . wp_create_nonce('_cred_customfield')); echo '<tr id="' . $field_id . '">'; 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 "cred_field_name": echo '<td ' . $attributes . '><strong><a class="thickbox" href="' . $editfieldpath . '" title="" title="' . __('Edit', 'wp-cred') . '">' . stripslashes($rec) . '</a>'; echo '</td>'; break; case "cred_cred_type": echo '<td ' . $attributes . '><span class="cred-field-type" style="margin-right:15px">' . $credfieldname . '</span></td>'; break; case "cred_actions": $actions = array('<a style="margin-right:10px" class="cred-field-actions _cred-field-set thickbox" href="' . $setfieldpath . '" title=\'' . esc_attr(__('Set field type', 'wp-cred')) . '\'>' . __('Add', 'wp-cred') . '</a>', '<a style="margin-right:10px" class="cred-field-actions _cred-field-edit thickbox" href="' . $editfieldpath . '" title=\'' . esc_attr(__('Edit field settings', 'wp-cred')) . '\'>' . __('Edit', 'wp-cred') . '</a>', '<a style="margin-right:10px" class="cred-field-actions _cred-field-remove" href="' . $removefieldpath . '" title=\'' . esc_attr(__('Remove this field as a CRED field type', 'wp-cred')) . '\'>' . __('Remove', 'wp-cred') . '</a>'); $act_out = implode('', $actions); echo '<td ' . $attributes . '>' . $act_out . '</td>'; break; } } echo '</tr>'; } }
/** * method forms the data output style * */ function display_rows() { $post_type = CRED_USER_FORMS_CUSTOM_POST_NAME; $path = admin_url('admin.php') . '?page=CRED_User_Forms'; //$editpath = admin_url('post.php').'?action=edit'; //Get the records registered in the prepare_items method $records = $this->items; //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; } $form_types = apply_filters('cred_admin_form_type_options', array("new" => __('Create user', 'wp-cred'), "edit" => __('Edit user', 'wp-cred')), '', null); foreach ($records as $rec) { $settings = isset($rec->meta) ? maybe_unserialize($rec->meta) : false; $editlink = CRED_CRED::getFormEditLink($rec->ID); //Open the line echo '<tr id="record_' . $rec->ID . '">'; $checkbox_id = "checkbox_" . $rec->ID; $checkbox = "<input type='checkbox' name='checked[]' value='" . $rec->ID . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $rec->post_title . "</label>"; $exportpath = CRED_CRED::route('/Forms/exportForm' . "?form={$rec->ID}&type=user&_wpnonce=" . wp_create_nonce('cred-export-' . $rec->ID)); 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 "cred_form_name": //$editlink = $editpath."&post=$rec->ID"; //$onclick_delete="if(confirm('".esc_js( sprintf( __( "Are you sure that you want to delete this form '%s'?\n\n Click [Cancel] to stop, [OK] to delete.", 'wp-cred' ), $rec->post_title ) ) . "' ) ) { return true;}return false;"; $onclick_clone = "var cred_form_title=prompt('" . esc_js(__('Title of New Form ', 'wp-cred')) . "','" . $rec->post_title . ' Copy' . "'); if (cred_form_title) {this.href+='&cred_form_title='+encodeURI(cred_form_title); return true;} else return false;"; $actions = array(); $actions['edit'] = '<a class="submitedit" href="' . $editlink . '" title=\'' . esc_attr(__('Edit', 'wp-cred')) . '\'>' . __('Edit', 'wp-cred') . '</a>'; $actions['clone'] = "<a class='submitclone' href='" . wp_nonce_url($path . "&action=clone&id={$rec->ID}", 'clone-form_' . $rec->ID) . "' onclick=\"" . $onclick_clone . "\">" . __('Clone', 'wp-cred') . "</a>"; $actions['export'] = '<a class="submitexport" target="_blank" href="' . $exportpath . '" title=\'' . esc_attr(__('Export', 'wp-cred')) . '\'>' . __('Export', 'wp-cred') . '</a>'; //$actions['delete'] = "<a class='submitdelete' href='".wp_nonce_url( $path."&action=delete&id=$rec->ID", 'delete-form_'.$rec->ID )."' onclick=\"".$onclick_delete."\">" . __( 'Delete', 'wp-cred') . "</a>"; $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url($path . "&action=delete&id={$rec->ID}", 'delete-form_' . $rec->ID) . "'>" . __('Delete', 'wp-cred') . "</a>"; echo '<td ' . $attributes . '><strong><a href="' . $editlink . '" title=\'' . esc_attr(__('Edit', 'wp-cred')) . '\'>' . stripslashes($rec->post_title) . '</a> (ID: ' . $rec->ID . ')</strong>'; echo $this->row_actions($actions); echo '</td>'; break; case "cred_form_type": if ($settings && !empty($settings->form['type']) && isset($form_types[stripslashes($settings->form['type'])])) { echo '<td ' . $attributes . '>' . $form_types[stripslashes($settings->form['type'])] . '</td>'; } else { echo '<td ' . $attributes . '><strong>' . __('Not Set', 'wp-cred') . '</strong></td>'; } break; case "cred_user_role": $r = empty($settings->form['user_role']) ? __('All', 'wp-cred') : $settings->form['user_role']; echo '<td ' . $attributes . '>' . $r . '</td>'; break; case "cred_post_type": // if ($settings && !empty($settings->post['post_type'])) { // $pt = stripslashes($settings->post['post_type']); // $pto = get_post_type_object($pt); // if ($pto) { // $ptname = $pto->labels->name; // } else { // $ptname = $pt . '  <span style="color:red">(' . __('NOT FOUND', 'wp-cred') . ')</span>'; // } // echo '<td ' . $attributes . '>' . $ptname . '</td>'; // } else echo '<td ' . $attributes . '><strong>' . __('User', 'wp-cred') . '</strong></td>'; break; // display extra columns (if hooked) // display extra columns (if hooked) default: ?> <td <?php echo $attributes; ?> ><?php do_action('manage_posts_custom_column', $column_name, $rec->ID); do_action("manage_{$post_type}_posts_custom_column", $column_name, $rec->ID); ?> </td> <?php break; } } echo '</tr>'; } }
function cred_cell_dialog_template_callback() { ob_start(); ?> <div class="ddl-form cred-edit-cells-form"> <?php if (defined('CRED_FORMS_CUSTOM_POST_NAME')) { ?> <?php require_once CRED_CLASSES_PATH . "/CRED.php"; if (method_exists('CRED_CRED', 'is_embedded')) { $cred_embedded = CRED_CRED::is_embedded(); } else { $cred_embedded = false; } ?> <?php if (!$cred_embedded) { ?> <fieldset> <div class="fields-group"> <label class="radio"> <input type="radio" name="cred-action" class="js-ddl-cred-form-create" value="new_form" > <?php _e('Create a new CRED Post Form', 'ddl-layouts'); ?> </label> <span class="desc ddl-form-indent js-ddl-newcred"><?php _e('CRED Post Forms allow you to create content or edit your content. Choose what you want this form to do and the type of content it will work with.', 'ddl-layouts'); ?> </span> <br class="js-ddl-newcred" /> </div> </fieldset> <fieldset class="js-ddl-newcred"> <legend><?php _e('This form will:', 'ddl-layouts'); ?> </legend> <select class="js-cred-new-mode ddl-form-indent"> <option value="new"><?php _e('Create content', 'ddl-layouts'); ?> </option> <option value="edit"><?php _e('Edit content', 'ddl-layouts'); ?> </option> </select> </fieldset> <fieldset class="js-ddl-newcred"> <?php $post_types = CRED_Loader::get('MODEL/Fields')->getPostTypes(); ?> <legend><?php _e('Content type:', 'ddl-layouts'); ?> </legend> <select class="js-cred-post-type ddl-form-indent"> <?php foreach ($post_types as $post_type) { ?> <option value="<?php echo $post_type['type']; ?> "><?php echo $post_type['name']; ?> </option> <?php } ?> </select> </fieldset> <fieldset class="js-ddl-newcred"> <div class="fields-group ddl-form-indent"> <button class="button button-primary js-ddl-create-cred-form"> <?php _e('Create Cell', 'ddl-layouts'); ?> </button> <p class="js-cred-form-create-error toolset toolset-alert-error alert ddl-form-input-alert" style="display:none"> </p> </div> </fieldset> <?php } // end of full cred. ?> <fieldset class="ddl-dialog-fieldset"> <div class="fields-group" <?php if ($cred_embedded) { echo 'style="display:none"'; } ?> > <label class="radio"> <input type="radio" name="cred-action" class="js-ddl-cred-form-existing" value="existing" > <?php _e('Use an existing CRED Post Form', 'ddl-layouts'); ?> </label> </div> </fieldset> <fieldset class="js-ddl-select-existing-cred"> <legend><?php _e('Form:', 'ddl-layouts'); ?> </legend> <select name="<?php the_ddl_name_attr('ddl_layout_cred_id'); ?> " class="ddl-cred-select js-ddl-cred-select <?php if (!$cred_embedded) { echo 'ddl-form-indent'; } ?> " data-new="<?php _e('create', 'ddl-layout'); ?> " data-edit="<?php _e('edit', 'ddl-layouts'); ?> "> <option value=""><?php _e('--- Select form ---', 'ddl-layouts'); ?> </option>'; <?php $fm = CRED_Loader::get('MODEL/Forms'); $posts = $fm->getAllForms(); foreach ($posts as $post) { $form = $fm->getForm($post->ID); echo $this->ddl_cred_get_option_element($post->ID, $post->post_title, $form->fields['form_settings']->form['type'], $form->fields['form_settings']->post['post_type']); } ?> </select> <?php if (!$cred_embedded) { ?> <div class="fields-group ddl-form-indent"> <button class="button button-primary js-ddl-edit-cred-link" data-close-cred-text="<?php _e('Save and Close this form and return to the layout', 'ddl-layouts'); ?> " data-discard-cred-text="<?php _e('Close this form and discard any changes', 'ddl-layouts'); ?> "> <?php _e('Create Cell', 'ddl-layouts'); ?> </button> </div> <?php } ?> </fieldset> <?php if ($cred_embedded) { ?> <fieldset> <div class="fields-group"> <div class="toolset-alert toolset-alert-info"> <?php _e('You are using the embedded version of CRED. Install and activate the full version of CRED and you will be able to create custom forms.', 'ddl-layouts'); ?> <br> <a class="fieldset-inputs" href="http://wp-types.com/home/cred/?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=cred-cell&utm_term=get-cred" target="_blank"> <?php _e('About CRED', 'ddl-layouts'); ?> </a> </div> </div> </fieldset> <?php } ?> <?php } else { ?> <div class="toolset-alert toolset-alert-info js-ddl-cred-not-activated"> <p> <i class="icon-cred-logo ont-color-orange ont-icon-24"></i> <?php _e('This cell requires the CRED plugin. Install and activate the CRED plugin and you will be able to create custom forms for creating and editing content.', 'ddl-layouts'); ?> <br> <br> <a class="fieldset-inputs" href="http://wp-types.com/home/cred/?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=cred-cell&utm_term=get-cred" target="_blank"> <?php _e('About CRED', 'ddl-layouts'); ?> </a> </p> </div> <?php } ?> <div> <?php ddl_add_help_link_to_dialog(WPDLL_CRED_CELL, __('Learn about the CRED Post Form cell', 'ddl-layouts')); ?> </div> </div> <div id="ddl-cred-preview" style="display:none"> - <p><strong><?php _e('This form is used to %EDIT% %POST_TYPE%', 'ddl-layouts'); ?> </strong></p> <div class="ddl-cred-preview"> <img src="<?php echo WPDDL_RES_RELPATH . '/images/cell-icons/cred-form.svg'; ?> " height="130px"> </div> </div> <div id="ddl-cred-preview-cred-not-found" style="display:none"> <h2><?php _e('The CRED Post Form was not found. It may have been deleted.', 'ddl-layouts'); ?> </h2> </div> <?php echo wp_nonce_field('ddl_layout_cred_nonce', 'ddl_layout_cred_nonce', true, false); return ob_get_clean(); }
domRef: '#notification_user_required-<?php echo $ii; ?> ' }, { action: 'validateSection' } ] } }, event: 'init', action: { suggest: { url: '<?php echo CRED_CRED::route('/Forms/suggestUserMail'); ?> ', param: 'user', loader: '#cred_notification_user_mail_suggest_loader_<?php echo $ii; ?> ' } } }" type="text" class="cred_mail_to_user" style="width:200px" name="_cred[notification][notifications][<?php echo $ii; ?> ][to][wp_user][user]" placeholder="<?php echo esc_attr(__('-- Choose user --', 'wp-cred'));
public static function cred_delete_post_link($post_id = false, $text = '', $action = '', $class = '', $style = '', $message = '', $message_after = '', $message_show = 1, $redirect = '') { global $post, $current_user; static $idcount = 0; if (!current_user_can('delete_own_posts_with_cred') && $current_user->ID == $post->post_author) { //return '<strong>'.__('Do not have permission (delete own)','wp-cred').'</strong>'; return ''; } if (!current_user_can('delete_other_posts_with_cred') && $current_user->ID != $post->post_author) { //return '<strong>'.__('Do not have permission (delete other)','wp-cred').'</strong>'; return ''; } if ($post_id === false || empty($post_id) || !isset($post_id) || !is_numeric($post_id)) { if (!isset($post->ID)) { return '<strong>' . __('No post specified', 'wp-cred') . '</strong>'; } else { $post_id = $post->ID; } } // localise the ID $post_id = self::getLocalisedID(intval($post_id)); // provide WPML localization for hardcoded texts $text = str_replace(array('%TITLE%', '%ID%'), array(get_the_title($post_id), $post_id), cred_translate('Delete Link Text', $text, 'CRED Shortcodes')); $link_id = '_cred_cred_' . $post_id . '_' . ++$idcount . '_' . rand(1, 10); $_wpnonce = wp_create_nonce($link_id . '_' . $action); $link = CRED_CRED::routeAjax('cred-ajax-delete-post&cred_post_id=' . $post_id . '&cred_action=' . $action . '&redirect=' . $redirect . '&_wpnonce=' . $_wpnonce); $_atts = array(); if (!empty($class)) { $_atts[] = 'class="' . esc_attr(str_replace('"', "'", $class)) . '"'; } if (!empty($style)) { $_atts[] = 'style="' . esc_attr(str_replace('"', "'", $style)) . '"'; } $dps = ""; if ($idcount == 1) { //$dps = self::get_delete_post_link_js($message_after); global $message_after; add_action('wp_footer', array('CRED_Helper', 'get_delete_post_link_js'), 100); } return CRED_Loader::tpl('delete-post-link', array('link' => $link, 'text' => $text, 'link_id' => $link_id, 'link_atts' => !empty($_atts) ? implode(' ', $_atts) : false, 'message' => $message, 'message_after' => $message_after, 'message_show' => $message_show, 'js' => $dps)); }
public static function addMenuItems() { $menu_label = CRED_NAME; //__( 'CRED','wp-cred' ); $url = 'post-new.php?post_type=' . CRED_FORMS_CUSTOM_POST_NAME; $cred_index = 'CRED_Forms'; //CRED_VIEWS_PATH2.'/forms.php'; add_menu_page($menu_label, $menu_label, 'manage_options', $cred_index, array('CRED_CRED', 'FormsMenuPage'), CRED_ASSETS_URL . '/images/cred_18x18_color.png'); add_submenu_page($cred_index, __('Forms', 'wp-cred'), __('Forms', 'wp-cred'), CRED_CAPABILITY, 'CRED_Forms', array('CRED_CRED', 'FormsMenuPage')); add_submenu_page($cred_index, __('New Form', 'wp-cred'), __('New Form', 'wp-cred'), CRED_CAPABILITY, $url); add_submenu_page($cred_index, __('Custom Fields', 'wp-cred'), __('Custom Fields', 'wp-cred'), CRED_CAPABILITY, 'CRED_Fields', array('CRED_CRED', 'FieldsMenuPage')); add_submenu_page($cred_index, __('Settings/Import', 'wp-cred'), __('Settings/Import', 'wp-cred'), CRED_CAPABILITY, 'CRED_Settings', array('CRED_CRED', 'SettingsMenuPage')); add_submenu_page($cred_index, __('Help', 'wp-cred'), __('Help', 'wp-cred'), CRED_CAPABILITY, 'CRED_Help', array('CRED_CRED', 'HelpMenuPage')); self::$screens = array($cred_index, CRED_VIEWS_PATH2 . '/custom_fields.php'); foreach (self::$screens as $screen) { add_action("load-" . $screen, array('CRED_CRED', 'add_screen_options')); } //add_filter('set-screen-option', array('CRED_CRED', 'set_screen_option'), 10, 3); }
if (action=='export-selected') { // nothing selected to export if (!checked.length) { event.preventDefault(); return false; } // prevent action from submission, it conflicts with ajax action param $('form#list select[name="action"]').attr('disabled','disabled'); event.preventDefault(); $.fileDownload('<?php echo CRED_CRED::route('/Forms/exportSelected?ajax=1'); ?> ',{ successCallback:function() { $('form#list select[name="action"]').removeAttr('disabled'); overlay_loader.hide(); }, beforeDownloadCallback:function() { overlay_loader.css({'background-position':'center '+(0.5*$win.height()+$win.scrollTop())+'px'}).show(); }, failCallback:function() { $('form#list select[name="action"]').removeAttr('disabled'); overlay_loader.hide(); cred.gui.Popups.alert({ message:'<?php echo esc_js(__('An error occurred please try again', 'wp-cred'));
if (action=='export-selected') { // nothing selected to export if (!checked.length) { event.preventDefault(); return false; } // prevent action from submission, it conflicts with ajax action param $('form#list select[name="action"]').attr('disabled','disabled'); event.preventDefault(); $.fileDownload('<?php echo CRED_CRED::route('/Forms/exportSelected?type=user&ajax=1'); ?> ',{ successCallback:function() { $('form#list select[name="action"]').removeAttr('disabled'); overlay_loader.hide(); }, beforeDownloadCallback:function() { overlay_loader.css({'background-position':'center '+(0.5*$win.height()+$win.scrollTop())+'px'}).show(); }, failCallback:function() { $('form#list select[name="action"]').removeAttr('disabled'); overlay_loader.hide(); cred.gui.Popups.alert({ message:'<?php echo esc_js(__('An error occurred please try again', 'wp-cred'));
</h3> <i title='<?php echo esc_attr(__('Close', 'wp-cred')); ?> ' class='icon-remove cred-close-button cred-cred-cancel-close'></i> </div> <div id="cred-generic-shortcodes-box-inner" class="cred-popup-inner"> <?php foreach ($gfields as $type => $field) { //Removing next row in order to fix this: https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/187372012/comments //if ($field['type']=='audio'||$field['type']=='video') continue; echo "<a href='" . CRED_CRED::route('/Generic_Fields/getField?field=' . $type . '&TB_iframe=true&width=500&height=450') . "' class='button thickbox cred_field_add' title='" . esc_js(sprintf(__('Insert Field type "%s"', 'wp-cred'), $field['title'])) . "'>" . $field['title'] . "</a>"; } ?> <a href='javascript:;' onclick="var _href='<?php echo CRED_CRED::route('/Generic_Fields/getField?field=conditional_group'); ?> &post_type='+jQuery('#cred_post_type').val()+'&TB_iframe=true&width=500&height=450';this.href=_href;return true;" class='button thickbox cred_field_add' title='<?php echo esc_attr(sprintf(__('Insert Field type "%s"', 'wp-cred'), __('Conditional Group', 'wp-cred'))); ?> '><?php _e('Conditional Group', 'wp-cred'); ?> </a> </div> <a class='cred-help-link' style='' href='<?php echo $help['generic_fields_settings']['link']; ?> ' target='<?php echo $help_target; ?>
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); }
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( )); */ }