コード例 #1
0
ファイル: admin.php プロジェクト: sabdev1/ljcdevsab
/**
 * Display the list of forms
 */
function iphorm_forms()
{
    $message = '';
    if (isset($_GET['action']) && $_GET['action'] == 'delete' && current_user_can('iphorm_delete_form')) {
        $id = isset($_GET['id']) ? absint($_GET['id']) : 0;
        if ($id && wp_verify_nonce($_GET['_wpnonce'], 'iphorm_delete_form_' . $id)) {
            $deleted = iphorm_delete_forms(array($id));
            if ($deleted) {
                $message = sprintf(_n('Form deleted', '%d forms deleted', $deleted, 'iphorm'), $deleted);
            }
        }
    }
    if (isset($_GET['action']) && $_GET['action'] == 'activate' && current_user_can('iphorm_build_form')) {
        $id = isset($_GET['id']) ? absint($_GET['id']) : 0;
        if ($id && wp_verify_nonce($_GET['_wpnonce'], 'iphorm_activate_form_' . $id)) {
            $activated = iphorm_activate_forms(array($id));
            if ($activated) {
                $message = sprintf(_n('Form activated', '%d forms activated', $activated, 'iphorm'), $activated);
            }
        }
    }
    if (isset($_GET['action']) && $_GET['action'] == 'deactivate' && current_user_can('iphorm_build_form')) {
        $id = isset($_GET['id']) ? absint($_GET['id']) : 0;
        if ($id && wp_verify_nonce($_GET['_wpnonce'], 'iphorm_deactivate_form_' . $id)) {
            $deactivated = iphorm_deactivate_forms(array($id));
            if ($deactivated) {
                $message = sprintf(_n('Form deactivated', '%d forms deactivated', $deactivated, 'iphorm'), $deactivated);
            }
        }
    }
    if (isset($_GET['action']) && $_GET['action'] == 'duplicate' && current_user_can('iphorm_build_form')) {
        $id = isset($_GET['id']) ? absint($_GET['id']) : 0;
        if ($id && wp_verify_nonce($_GET['_wpnonce'], 'iphorm_duplicate_form_' . $id)) {
            $config = iphorm_get_form_config($id);
            if (is_array($config)) {
                $config['name'] .= ' (' . __('duplicate', 'iphorm') . ')';
            }
            $config = iphorm_add_form($config);
            if (is_array($config)) {
                $message = sprintf(esc_html__('Form duplicated, %sedit the form%s', 'iphorm'), '<a href="' . admin_url('admin.php?page=iphorm_form_builder&amp;id=' . $config['id']) . '">', '</a>');
            }
        }
    }
    $bulkAction = '';
    if (isset($_POST['bulk_action']) && $_POST['bulk_action'] != '-1') {
        $bulkAction = $_POST['bulk_action'];
    } elseif (isset($_POST['bulk_action2']) && $_POST['bulk_action2'] != '-1') {
        $bulkAction = $_POST['bulk_action2'];
    }
    if ($bulkAction == 'delete' && isset($_POST['form']) && current_user_can('iphorm_delete_form')) {
        $deleted = iphorm_delete_forms($_POST['form']);
        if ($deleted) {
            $message = sprintf(_n('Form deleted', '%d forms deleted', $deleted, 'iphorm'), $deleted);
        }
    } else {
        if ($bulkAction == 'activate' && isset($_POST['form']) && current_user_can('iphorm_build_form')) {
            $activated = iphorm_activate_forms($_POST['form']);
            if ($activated) {
                $message = sprintf(_n('Form activated', '%d forms activated', $activated, 'iphorm'), $activated);
            }
        } else {
            if ($bulkAction == 'deactivate' && isset($_POST['form']) && current_user_can('iphorm_build_form')) {
                $deactivated = iphorm_deactivate_forms($_POST['form']);
                if ($deactivated) {
                    $message = sprintf(_n('Form deactivated', '%d forms deactivated', $deactivated, 'iphorm'), $deactivated);
                }
            }
        }
    }
    $active = isset($_GET['active']) ? absint($_GET['active']) : null;
    $forms = iphorm_get_all_form_rows($active);
    include IPHORM_ADMIN_INCLUDES_DIR . '/forms.php';
}
コード例 #2
0
ファイル: common.php プロジェクト: sabdev1/ljcdevsab
/**
 * Get all the forms from the database
 *
 * @param int $active 1 or 0 to get only active or inactive forms
 * @return array An array of form configs
 */
function iphorm_get_all_forms($active = null)
{
    $forms = array();
    $rows = iphorm_get_all_form_rows($active);
    if (count($rows)) {
        foreach ($rows as $row) {
            $forms[] = maybe_unserialize($row->config);
        }
    }
    return $forms;
}
コード例 #3
0
ファイル: widget.php プロジェクト: sabdev1/ljcdevsab
    /**
     * Display the widget settings form
     *
     * @param  array  $instance  The current settings for this widget instance
     */
    public function form($instance)
    {
        $formRows = iphorm_get_all_form_rows();
        if (!isset($instance['title'])) {
            $instance['title'] = '';
        }
        if (!isset($instance['form_id'])) {
            $instance['form_id'] = 0;
        }
        if (!isset($instance['content'])) {
            $instance['content'] = '';
        }
        if (!isset($instance['options'])) {
            $instance['options'] = '';
        }
        ?>
        <?php 
        if (count($formRows)) {
            ?>
        <div>
            <label for="<?php 
            echo $this->get_field_id('title');
            ?>
"><?php 
            esc_html_e('Title (optional)', 'iphorm');
            ?>
</label>
            <input type="text" class="widefat" id="<?php 
            echo $this->get_field_id('title');
            ?>
" name="<?php 
            echo $this->get_field_name('title');
            ?>
" value="<?php 
            echo esc_attr($instance['title']);
            ?>
" />
        </div>
        <div style="margin-top: 10px;">
            <label for="<?php 
            echo $this->get_field_id('form_id');
            ?>
"><?php 
            esc_html_e('Select a form', 'iphorm');
            ?>
</label>
            <select id="<?php 
            echo $this->get_field_id('form_id');
            ?>
" name="<?php 
            echo $this->get_field_name('form_id');
            ?>
">
            <?php 
            foreach ($formRows as $formRow) {
                ?>
                <?php 
                $config = iphorm_get_form_config($formRow->id);
                ?>
                <option value="<?php 
                echo absint($config['id']);
                ?>
" <?php 
                selected($instance['form_id'], $config['id']);
                ?>
><?php 
                echo esc_html($config['name']);
                ?>
</option>
            <?php 
            }
            ?>
            </select>
        </div>
        <div style="margin-top: 10px;">
            <label for="<?php 
            echo $this->get_field_id('content');
            ?>
"><?php 
            esc_html_e('Text or HTML to trigger the popup', 'iphorm');
            ?>
</label>
            <textarea id="<?php 
            echo $this->get_field_id('content');
            ?>
" name="<?php 
            echo $this->get_field_name('content');
            ?>
" class="widefat"><?php 
            echo esc_attr($instance['content']);
            ?>
</textarea>
        </div>
        <div style="margin-top: 10px;">
            <label for="<?php 
            echo $this->get_field_id('options');
            ?>
"><?php 
            esc_html_e('Fancybox options (advanced)', 'iphorm');
            ?>
</label>
            <input type="text" class="widefat" name="<?php 
            echo $this->get_field_name('options');
            ?>
" id="<?php 
            echo $this->get_field_id('options');
            ?>
" value="<?php 
            echo esc_attr($instance['options']);
            ?>
" />
            <p class="description" style="margin-bottom: 3px;"><?php 
            printf(esc_html__('Enter any Fancybox options as a JSON formatted string, %sexample%s.', 'iphorm'), '<a href="' . admin_url('admin.php?page=iphorm_help&amp;section=faq#website-lightbox-widget-options') . '" onclick="window.open(this.href); return false;">', '</a>');
            ?>
</p>
        </div>
        <?php 
        } else {
            ?>
            <?php 
            printf(esc_html__('You have not created a form yet, %sclick here to create one%s.', 'iphorm'), '<a href="' . admin_url('admin.php?page=iphorm_form_builder') . '">', '</a>');
            ?>
        <?php 
        }
        ?>
        <?php 
    }