Example #1
0
/**
 * Adds an "Insert Donation Form" button above the TinyMCE Editor on add/edit screens.
 *
 * @since 1.0
 * @return string "Add Donation Form" Button
 */
function give_media_button()
{
    global $pagenow, $typenow, $wp_version;
    $output = '';
    /** Only run in post/page creation and edit screens */
    if (in_array($pagenow, array('post.php', 'page.php', 'post-new.php', 'post-edit.php')) && $typenow != 'give_forms' && $typenow != 'give_campaigns') {
        /* check current WP version */
        if (version_compare($wp_version, '3.5', '<')) {
            $img = '<img src="' . GIVE_PLUGIN_URL . 'assets/images/give-media.png" alt="' . sprintf(__('Add Donation %s', 'give'), give_get_forms_label_singular()) . '"/>';
            $output = '<a href="#TB_inline?width=640&inlineId=choose-give-form" class="thickbox" title="' . __('Add Donation Form', 'give') . '">' . $img . '</a>';
        } else {
            $img = '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image:url(' . give_svg_icons('give_grey') . ');margin-right:5px;"></span>';
            $output = '<a href="#TB_inline?width=640&inlineId=choose-give-form" class="thickbox button give-thickbox" title="' . sprintf(__('Add Donation %s', 'give'), give_get_forms_label_singular()) . '" style="padding-left: .4em;">' . $img . sprintf(__('Add Donation %s', 'give'), give_get_forms_label_singular()) . '</a>';
        }
    }
    echo $output;
}
Example #2
0
/**
 * Registers and sets up the Downloads custom post type
 *
 * @since 1.0
 * @return void
 */
function give_setup_post_types()
{
    /** Give Forms Post Type */
    $give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false;
    $give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false;
    $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations';
    //support for old 'GIVE_FORMS_SLUG' constant
    if (defined('GIVE_FORMS_SLUG')) {
        $give_forms_slug = GIVE_FORMS_SLUG;
    }
    $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array('slug' => $give_forms_slug, 'with_front' => false);
    $give_forms_labels = apply_filters('give_forms_labels', array('name' => '%2$s', 'singular_name' => '%1$s', 'add_new' => __('Add %1$s', 'give'), 'add_new_item' => __('Add New %1$s', 'give'), 'edit_item' => __('Edit %1$s', 'give'), 'new_item' => __('New %1$s', 'give'), 'all_items' => __('All %2$s', 'give'), 'view_item' => __('View %1$s', 'give'), 'search_items' => __('Search %2$s', 'give'), 'not_found' => __('No %2$s found', 'give'), 'not_found_in_trash' => __('No %2$s found in Trash', 'give'), 'parent_item_colon' => '', 'menu_name' => apply_filters('give_menu_name', __('Donations', 'give')), 'name_admin_bar' => apply_filters('give_name_admin_bar_name', __('Donation Form', 'give'))));
    foreach ($give_forms_labels as $key => $value) {
        $give_forms_labels[$key] = sprintf($value, give_get_forms_label_singular(), give_get_forms_label_plural());
    }
    //Default give_forms supports
    $give_form_supports = array('title', 'thumbnail', 'excerpt', 'revisions', 'author');
    //Has the user disabled the excerpt
    if (give_get_option('disable_forms_excerpt') === 'on') {
        unset($give_form_supports[2]);
    }
    //Has user disabled the featured image?
    if (give_get_option('disable_form_featured_img') === 'on') {
        unset($give_form_supports[1]);
        remove_action('give_before_single_form_summary', 'give_show_form_images');
    }
    $give_forms_args = array('labels' => $give_forms_labels, 'public' => true, 'publicly_queryable' => $give_forms_singular, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => $give_forms_rewrite, 'map_meta_cap' => true, 'capability_type' => 'give_forms', 'has_archive' => $give_forms_archives, 'menu_icon' => give_svg_icons('give_cpt_icon'), 'hierarchical' => false, 'supports' => apply_filters('give_forms_supports', $give_form_supports));
    register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args));
    /** Give Campaigns Post Type */
    $give_campaigns_archives = defined('GIVE_DISABLE_CAMPAIGNS_ARCHIVE') && GIVE_DISABLE_CAMPAIGNS_ARCHIVE ? false : true;
    $give_campaigns_slug = defined('GIVE_CAMPAIGNS_SLUG') ? GIVE_CAMPAIGNS_SLUG : 'campaigns';
    $give_campaigns_rewrite = defined('GIVE_DISABLE_CAMPAIGNS_REWRITE') && GIVE_DISABLE_CAMPAIGNS_REWRITE ? false : array('slug' => $give_campaigns_slug, 'with_front' => false);
    $give_campaigns_labels = apply_filters('give_campaign_labels', array('name' => '%2$s', 'singular_name' => '%1$s', 'add_new' => __('Add %1$s', 'give'), 'add_new_item' => __('Add New %1$s', 'give'), 'edit_item' => __('Edit %1$s', 'give'), 'new_item' => __('New %1$s', 'give'), 'all_items' => __('All %2$s', 'give'), 'view_item' => __('View %1$s', 'give'), 'search_items' => __('Search %2$s', 'give'), 'not_found' => __('No %2$s found', 'give'), 'not_found_in_trash' => __('No %2$s found in Trash', 'give'), 'parent_item_colon' => ''));
    foreach ($give_campaigns_labels as $key => $value) {
        $give_campaigns_labels[$key] = sprintf($value, give_get_campaigns_label_singular(), give_get_campaigns_label_plural());
    }
    $give_campaigns_args = array('labels' => $give_campaigns_labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => 'edit.php?post_type=give_forms', 'query_var' => true, 'rewrite' => $give_campaigns_rewrite, 'map_meta_cap' => true, 'capability_type' => 'give_campaigns', 'has_archive' => $give_campaigns_archives, 'hierarchical' => false, 'supports' => apply_filters('give_campaigns_supports', array('title', 'thumbnail', 'excerpt', 'revisions', 'author')));
    //	register_post_type( 'give_campaigns', apply_filters( 'give_campaigns_post_type_args', $give_campaigns_args ) );
    /** Payment Post Type */
    $payment_labels = array('name' => _x('Donations', 'post type general name', 'give'), 'singular_name' => _x('Donation', 'post type singular name', 'give'), 'add_new' => __('Add New', 'give'), 'add_new_item' => __('Add New Donation', 'give'), 'edit_item' => __('Edit Donation', 'give'), 'new_item' => __('New Donation', 'give'), 'all_items' => __('All Donations', 'give'), 'view_item' => __('View Donation', 'give'), 'search_items' => __('Search Donations', 'give'), 'not_found' => __('No Donations found', 'give'), 'not_found_in_trash' => __('No Donations found in Trash', 'give'), 'parent_item_colon' => '', 'menu_name' => __('Transactions', 'give'));
    $payment_args = array('labels' => apply_filters('give_payment_labels', $payment_labels), 'public' => false, 'query_var' => false, 'rewrite' => false, 'map_meta_cap' => true, 'capability_type' => 'give_payment', 'supports' => array('title'), 'can_export' => true);
    register_post_type('give_payment', $payment_args);
}
Example #3
0
 /**
  * Adds the "Donation Form" button above the TinyMCE Editor on add/edit screens.
  *
  * @return string
  *
  * @since 1.0
  */
 public function shortcode_button()
 {
     global $pagenow, $wp_version;
     $shortcode_button_pages = array('post.php', 'page.php', 'post-new.php', 'post-edit.php');
     // Only run in admin post/page creation and edit screens
     if (in_array($pagenow, $shortcode_button_pages) && apply_filters('give_shortcode_button_condition', true) && !empty(self::$shortcodes)) {
         $shortcodes = array();
         foreach (self::$shortcodes as $shortcode => $values) {
             /**
              * Filters the condition for including the current shortcode
              *
              * @since 1.0
              */
             if (apply_filters(sanitize_title($shortcode) . '_condition', true)) {
                 $shortcodes[$shortcode] = sprintf('<div class="sc-shortcode mce-menu-item give-shortcode-item-%1$s" data-shortcode="%s">%s</div>', $shortcode, $values['label'], $shortcode);
             }
         }
         if (!empty($shortcodes)) {
             // check current WP version
             $img = version_compare($wp_version, '3.5', '<') ? '<img src="' . GIVE_PLUGIN_URL . 'assets/images/give-media.png" />' : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons('give_grey') . ');"></span>';
             reset($shortcodes);
             if (count($shortcodes) == 1) {
                 $shortcode = key($shortcodes);
                 printf('<button class="button sc-shortcode" data-shortcode="%s">%s</button>', $shortcode, sprintf('%s %s %s', $img, __('Insert', 'give'), self::$shortcodes[$shortcode]['label']));
             } else {
                 printf('<div class="sc-wrap">' . '<button class="button sc-button">%s %s</button>' . '<div class="sc-menu mce-menu">%s</div>' . '</div>', $img, __('Give Shortcodes', 'give'), implode('', array_values($shortcodes)));
             }
         }
     }
 }