本文整理汇总了PHP中WPCF7_ContactForm::find方法的典型用法代码示例。如果您正苦于以下问题:PHP WPCF7_ContactForm::find方法的具体用法?PHP WPCF7_ContactForm::find怎么用?PHP WPCF7_ContactForm::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPCF7_ContactForm
的用法示例。
在下文中一共展示了WPCF7_ContactForm::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: yith_ypop_wpcf7_get_contact_forms
function yith_ypop_wpcf7_get_contact_forms()
{
if (!function_exists('wpcf7_contact_form')) {
return array('' => __('Plugin not activated or not installed', 'ypop'));
}
$posts = WPCF7_ContactForm::find();
foreach ($posts as $post) {
$array[$post->id()] = $post->title();
}
if (empty($array)) {
return array('' => __('No contact form found', 'ypop'));
}
return $array;
}
示例2: prepare_items
function prepare_items()
{
$current_screen = get_current_screen();
$per_page = $this->get_items_per_page('cfseven_contact_forms_per_page');
$this->_column_headers = $this->get_column_info();
$args = array('posts_per_page' => $per_page, 'orderby' => 'title', 'order' => 'ASC', 'offset' => ($this->get_pagenum() - 1) * $per_page);
if (!empty($_REQUEST['s'])) {
$args['s'] = $_REQUEST['s'];
}
if (!empty($_REQUEST['orderby'])) {
if ('title' == $_REQUEST['orderby']) {
$args['orderby'] = 'title';
} elseif ('author' == $_REQUEST['orderby']) {
$args['orderby'] = 'author';
} elseif ('date' == $_REQUEST['orderby']) {
$args['orderby'] = 'date';
}
}
if (!empty($_REQUEST['order'])) {
if ('asc' == strtolower($_REQUEST['order'])) {
$args['order'] = 'ASC';
} elseif ('desc' == strtolower($_REQUEST['order'])) {
$args['order'] = 'DESC';
}
}
$this->items = WPCF7_ContactForm::find($args);
$total_items = WPCF7_ContactForm::count();
$total_pages = ceil($total_items / $per_page);
$this->set_pagination_args(array('total_items' => $total_items, 'total_pages' => $total_pages, 'per_page' => $per_page));
}
示例3: get_items
/**
* Get dropdown items.
*
* @return array
*/
protected function get_items()
{
$forms = WPCF7_ContactForm::find();
return array_reduce($forms, function ($result, $form) {
$result[$form->title] = $form->id;
return $result;
}, array());
}
示例4: render
public function render($atts)
{
extract($atts);
$shortcode = '';
// Hookup the shortcode
if ($this->is_active()) {
$items = WPCF7_ContactForm::find(array('p' => $form_id));
}
if (!empty($items)) {
$item = $items[0];
$shortcode = sprintf('[contact-form-7 id="%1$d" title="%2$s"]', $item->id(), $item->title());
}
return $shortcode;
}
示例5: mab_cf7_meta_box
/**
* Outputs the CF7 options metabox in action box edit screen
* @param object $post the current post
* @return html
*/
function mab_cf7_meta_box($post)
{
$MabBase = MAB();
$MabButton = MAB('button');
$data['meta'] = $MabBase->get_mab_meta($post->ID);
$type = $MabBase->get_action_box_type($post->ID);
//Get contact form 7 stuff
$args = array('orderby' => 'title', 'order' => 'ASC');
$cf7_list = WPCF7_ContactForm::find($args);
$data['cf7-list'] = is_array($cf7_list) ? $cf7_list : array();
$data['buttons'] = $MabButton->getConfiguredButtons();
$filename = 'metabox/cf7-settings.php';
$box = mab_cf7_get_view($filename, $data);
echo $box;
}
示例6: wpcf7_prepend_underscore
function wpcf7_prepend_underscore($new_ver, $old_ver)
{
if (version_compare($old_ver, '3.0-dev', '<')) {
return;
}
if (!version_compare($old_ver, '3.3-dev', '<')) {
return;
}
$posts = WPCF7_ContactForm::find(array('post_status' => 'any', 'posts_per_page' => -1));
foreach ($posts as $post) {
$props = $post->get_properties();
foreach ($props as $prop => $value) {
if (metadata_exists('post', $post->id, '_' . $prop)) {
continue;
}
update_post_meta($post->id, '_' . $prop, $value);
delete_post_meta($post->id, $prop);
}
}
}
示例7: sandwich_contact_form_7
function sandwich_contact_form_7()
{
// Check if Shortcake exists
if (!function_exists('shortcode_ui_register_for_shortcode')) {
return;
}
if (!is_admin()) {
return;
}
if (!class_exists('WPCF7_ContactForm')) {
return;
}
$options = array('0' => sprintf('— %s —', __('Select', 'pbsandwich')));
$forms = WPCF7_ContactForm::find();
foreach ($forms as $form) {
$options[$form->id()] = $form->title();
}
// Register Shortcake UI
shortcode_ui_register_for_shortcode('contact-form-7', array('label' => __('Contact Form 7', 'contact-form-7'), 'listItemImage' => 'dashicons-email', 'attrs' => array(array('label' => __('Select a contact form', 'pbsandwich'), 'attr' => 'id', 'type' => 'select', 'options' => $options), array('label' => __('Title', 'pbsandwich'), 'attr' => 'title', 'type' => 'text', 'value' => ''))));
}
示例8: _e
</option>
<?php
}
?>
</select></td>
</tr>
<tr>
<td><input type='checkbox' name='use_contactform7'/></td>
<td><?php
_e('Use ContactForm7', 'dvinwcql');
?>
- <select name='contactform7_form_select' id='contactform7_form_select'>
<option value=''>Select Form</option>
<?php
if (class_exists('WPCF7_ContactForm')) {
$forms = WPCF7_ContactForm::find();
} else {
$forms = array();
}
foreach ($forms as $form) {
?>
<option value='<?php
echo $form->id();
?>
'><?php
echo $form->title();
?>
</option>
<?php
}
?>
示例9: get_forms
/**
* Get all forms running on the site
*
* @since 1.0.0
*
* @param $form_list
*
* @return mixed
*/
public function get_forms($form_list)
{
if (class_exists('Caldera_Forms')) {
$forms = \Caldera_Forms::get_forms();
$form_list['caldera'] = array('name' => __('Caldera Forms', 'caldera-forms'), 'forms' => array());
foreach ($forms as $form) {
$form_list['caldera']['forms'][$form['ID']] = $form['name'];
}
}
if (class_exists('RGFormsModel')) {
$forms = \RGFormsModel::get_forms(null, 'title');
$form_list['gform'] = array('name' => __('Gravity Forms', 'gravityforms'), 'forms' => array());
foreach ($forms as $form) {
$form_list['gform']['forms'][$form->id] = $form->title;
}
}
if (class_exists('NF_Forms')) {
$nforms = new \NF_Forms();
$nforms = $nforms->get_all();
$form_list['ninja'] = array('name' => __('Ninja Forms', 'ninja-forms'), 'forms' => array());
foreach ($nforms as $form) {
$form_list['ninja']['forms'][$form] = Ninja_Forms()->form($form)->get_setting('form_title');
}
}
if (class_exists('WPCF7_ContactForm')) {
$cforms = \WPCF7_ContactForm::find(array('posts_per_page' => -1));
$form_list['cf7'] = array('name' => __('Contact Form 7', 'contact-form-7'), 'forms' => array());
foreach ($cforms as $form) {
$form_list['cf7']['forms'][$form->id()] = $form->title();
}
}
if (class_exists('FrmForm')) {
$fforms = \FrmForm::getAll();
$form_list['frmid'] = array('name' => __('Formidable', 'formidable'), 'forms' => array());
foreach ($fforms as $form) {
if (!empty($form->is_template)) {
continue;
}
$form_list['frmid']['forms'][$form->id] = $form->name;
}
}
// jetpack
if (function_exists('grunion_display_form_view')) {
global $wpdb;
$shortcodes = $wpdb->get_results("SELECT `post_id` FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = '_g_feedback_shortcode';", ARRAY_A);
if (!empty($shortcodes)) {
$form_list['jp'] = array('name' => __('Jetpack Contact Form', 'jetpack'), 'forms' => array());
foreach ($shortcodes as $post_id) {
$form = get_post($post_id['post_id']);
$form_list['jp']['forms'][$post_id['post_id']] = $form->post_title;
}
}
}
return $form_list;
}
示例10: youxi_shortcode_cf7_forms
function youxi_shortcode_cf7_forms()
{
$array = array();
$forms = WPCF7_ContactForm::find();
foreach ($forms as $form) {
if (version_compare(WPCF7_VERSION, '3.9') >= 0) {
$array[$form->id()] = $form->title();
} else {
$array[$form->id] = $form->title;
}
}
return $array;
}
示例11: wpcf7_admin_bulk_validate_page
function wpcf7_admin_bulk_validate_page()
{
$contact_forms = WPCF7_ContactForm::find();
$count = WPCF7_ContactForm::count();
$submit_text = sprintf(_n("Validate %s Contact Form Now", "Validate %s Contact Forms Now", $count, 'contact-form-7'), number_format_i18n($count));
?>
<div class="wrap">
<h1><?php
echo esc_html(__('Validate Configuration', 'contact-form-7'));
?>
</h1>
<form method="post" action="">
<input type="hidden" name="action" value="validate" />
<?php
wp_nonce_field('wpcf7-bulk-validate');
?>
<p><input type="submit" class="button" value="<?php
echo esc_attr($submit_text);
?>
" /></p>
</form>
<?php
echo wpcf7_link(__('http://contactform7.com/configuration-validator-faq/', 'contact-form-7'), __('FAQ about Configuration Validator', 'contact-form-7'));
?>
</div>
<?php
}
示例12: wpcf7_get_contact_forms
/**
* Get list of forms by Contact Form 7 plugin
*
* @param $array array
* @since 1.0.0
* @author Alberto Ruggiero
* @return array
*/
public function wpcf7_get_contact_forms($array = array())
{
if (!function_exists('wpcf7_contact_form')) {
return array('' => __('Plugin not activated or not installed', 'ywctm'));
}
$posts = WPCF7_ContactForm::find();
foreach ($posts as $post) {
$array[$post->id()] = $post->title();
}
if ($array == array()) {
return array('' => __('No contact form found', 'ywctm'));
}
return $array;
}
示例13: add_enabled_icon
/**
* Add an icon to forms with Constant Contact integration enabled on the Contact Form 7 Edit page.
*
*/
static function add_enabled_icon()
{
global $pagenow, $plugin_page;
if (empty($plugin_page) || empty($pagenow)) {
return;
}
if ($pagenow === 'admin.php' && $plugin_page === 'wpcf7' && !isset($_GET['action']) && class_exists('WPCF7_ContactForm')) {
// Get the forms
$forms = WPCF7_ContactForm::find();
// If there are no forms, return
if (empty($forms)) {
return;
}
// Otherwise, loop through and see which ones have settings
// for Constant Contact integration.
$activeforms = array();
foreach ($forms as &$form) {
$is_active = get_option('cf7_ctct_' . $form->id);
if (!empty($is_active) && !empty($is_active['active'])) {
$activeforms[] = $form->id;
}
}
// Reset the post data, possibly modified by `WPCF7_ContactForm::find()`.
wp_reset_postdata();
// If there are no forms with CTCT integration, get outta here
if (empty($activeforms)) {
return;
}
// Otherwise, add the icon to each row with integration.
?>
<style>
.ctct_enabled {
position: absolute;
background: url('<?php
echo plugins_url('favicon.png', __FILE__);
?>
') right top no-repeat;
height: 16px;
width: 16px;
margin-left: 10px;
}
</style>
<script>
jQuery(document).ready(function($) {
// Convert forms array into JSON array
$activeforms = $.parseJSON('<?php
echo json_encode($activeforms);
?>
');
// For each visible forms row
$('table.posts tr').each(function() {
// Get the ID of the row
id = parseInt($('.check-column input', $(this)).val());
// If the row is in the $activeforms array, add the icon span
if($activeforms.indexOf(id) >= 0) {
$('td a.row-title', $(this)).append('<span class="ctct_enabled" title="Constant Contact integration is enabled for this form."></span>');
}
});
});
</script>
<?php
}
}
示例14: print_submit_form_actions_content
protected function print_submit_form_actions_content($submit_form_actions)
{
$cf7 = is_plugin_active('contact-form-7/wp-contact-form-7.php');
$gf = is_plugin_active('gravityforms/gravityforms.php');
foreach ($submit_form_actions as $action) {
$form_id = $action->get_form_id();
$type = "";
$name = "";
$link = "";
$mode = "";
$form = "";
$icon = "";
switch ($action->get_type()) {
case NelioABAction::SUBMIT_CF7_FORM:
$icon = "fa-check-square";
$type = "Contact Form 7";
if ($cf7) {
$aux = WPCF7_ContactForm::find(array('p' => $form_id));
if (count($aux) > 0) {
$form = $aux[0];
$name = $form->title();
$link = admin_url('admin.php?page=wpcf7&action=edit&post=' . $form_id);
}
}
$mode = __('from the tested page', 'nelioab');
if ($action->accepts_submissions_from_any_page()) {
$mode = __('from any page', 'nelioab');
}
break;
case NelioABAction::SUBMIT_GRAVITY_FORM:
$icon = "fa-check-square-o";
$type = "Gravity Forms";
$mode = __('from the tested page', 'nelioab');
if ($action->accepts_submissions_from_any_page()) {
$mode = __('from any page', 'nelioab');
}
if ($gf) {
$form = GFAPI::get_form($form_id);
if ($form) {
$name = $form['title'];
$link = admin_url('admin.php?page=gf_edit_forms&id=' . $form_id);
}
}
break;
}
if (!$name) {
$name = __("Unknown Form", "nelioab");
}
$submission = sprintf(__('%1$s submission', 'nelioab'), $type);
$html = <<<HTML
\t\t\t\t<div class="nelio-form-submission-action nelio-action-item">
\t\t\t\t\t<i class="fa {$icon}"></i>
\t\t\t\t\t<span class="form-info">{$submission} ({$mode}):</span>
\t\t\t\t\t<span class="form-value">
\t\t\t\t\t\t<a class="button" href="{$link}" target="_blank">
\t\t\t\t\t\t\t{$name}
\t\t\t\t\t\t\t<i class="fa fa-pencil"></i>
\t\t\t\t\t\t</a>
\t\t\t\t\t</span>
\t\t\t\t</div>
HTML;
echo $html;
}
}
示例15: search_forms
/**
* This function is an AJAX callback that looks for forms.
*
* It returns a list of up to 20 forms. The forms can either be Gravity
* Forms or Contact Form 7 forms. It is used by the select2 widget (an item
* selector that looks more beautiful than regular the "select>option"
* combo.
*
* Accepted POST params are:
*
* * term: {string} the (part of the) string used to look for items.
* * type: {'cf7','gf'} we may look for Contact Forms 7 (cf7) or Gravity
* Forms (gf)
* * default_id: {int} (optional) if set, the item with that ID will be
* returned. If that item is not found, then we'll perform a regular search
* (as if the param had not been set).
*
* @return array a list of forms.
*
* @since PHPDOC
*/
public static function search_forms()
{
$term = false;
if (isset($_POST['term'])) {
$term = $_POST['term'];
}
$type = false;
if (isset($_POST['type'])) {
$type = $_POST['type'];
}
$default_id = false;
if (isset($_POST['default_id'])) {
$default_id = $_POST['default_id'];
}
$default_thumbnail = sprintf('<img src="data:image/gif;%s" class="%s" alt="%s" />', 'base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', 'attachment-thumbnail wp-post-image nelioab-no-thumbnail', __('No featured image available', 'nelioab'));
$args = array('s' => $term, 'posts_per_page' => 20, 'order' => 'asc', 'orderby' => 'title');
// If there's a default_id set, it means that the user is interested
// in one form only; I'm going to return that form to him
if ($default_id !== false && $default_id > 0) {
if ('cf7' == $type && class_exists('WPCF7_ContactForm')) {
/** @noinspection PhpUndefinedClassInspection */
$aux = WPCF7_ContactForm::find(array('p' => $default_id));
if (count($aux) > 0) {
/**
* @var object $form
* @method int id()
* @method string title()
*/
$form = $aux[0];
$item = array('id' => $form->id(), 'title' => self::fix_title($form->title()), 'type' => 'Contact Form 7', 'thumbnail' => $default_thumbnail);
header('Content-Type: application/json');
echo json_encode(array($item));
die;
}
} elseif ('gf' == $type && class_exists('GFAPI')) {
/** @noinspection PhpUndefinedClassInspection */
$form = GFAPI::get_form($default_id);
if ($form) {
$item = array('id' => $form['id'], 'title' => self::fix_title($form['title']), 'thumbnail' => $default_thumbnail);
header('Content-Type: application/json');
echo json_encode(array($item));
die;
}
}
}
$result = array();
if ('cf7' == $type && class_exists('WPCF7_ContactForm')) {
/** @noinspection PhpUndefinedClassInspection */
$forms = WPCF7_ContactForm::find($args);
foreach ($forms as $form) {
/**
* @var object $form
* @method int id()
* @method string title()
*/
$item = array('id' => $form->id(), 'title' => self::fix_title($form->title()), 'type' => 'Contact Form 7', 'thumbnail' => $default_thumbnail);
array_push($result, $item);
}
} elseif ('gf' == $type && class_exists('RGFormsModel')) {
/** @noinspection PhpUndefinedClassInspection */
$forms = RGFormsModel::get_forms();
foreach ($forms as $form) {
if ($term && strpos(strtolower($form->title), strtolower($term)) === false) {
continue;
}
$item = array('id' => $form->id, 'title' => self::fix_title($form->title), 'type' => 'Gravity Form', 'thumbnail' => $default_thumbnail);
array_push($result, $item);
}
}
header('Content-Type: application/json');
echo json_encode($result);
die;
}