Plugin Directory

Changeset 2891046


Ignore:
Timestamp:
03/31/2023 09:08:11 AM (3 years ago)
Author:
setupad
Message:

Shortcode insertion and bug fixes

Location:
setupad/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • setupad/trunk/admin/assets/css/custom.css

    r2881084 r2891046  
    1919
    2020.setupad-image { display: none;}
     21.setupad-shortcode { display: none;}
    2122.setupad-after-position { display: none;}
    2223
  • setupad/trunk/admin/assets/js/setupad.js

    r2881084 r2891046  
    5959                    jQuery(".setupad-content").show();
    6060                    jQuery(".setupad-image").hide();
     61                    jQuery(".setupad-shortcode").hide();
     62                    jQuery(".setupad-lazy-loading").show();
    6163                } else if(element.value ==="images") {
    6264                    jQuery(".setupad-content").hide();
    6365                    jQuery(".setupad-image").show();
     66                    jQuery(".setupad-shortcode").hide();
     67                    jQuery(".setupad-lazy-loading").show();
     68                } else if(element.value ==="shortcode") {
     69                    jQuery(".setupad-content").hide();
     70                    jQuery(".setupad-image").hide();
     71                    jQuery(".setupad-shortcode").show();
     72                    jQuery(".setupad-lazy-loading").hide();
    6473                }
    6574            }
     
    7180                jQuery(".setupad-content").show();
    7281                jQuery(".setupad-image").hide();
     82                jQuery(".setupad-shortcode").hide();
     83                jQuery(".setupad-lazy-loading").show();
    7384            } else if(position ==="images") {
    7485                jQuery(".setupad-content").hide();
    7586                jQuery(".setupad-image").show();
     87                jQuery(".setupad-shortcode").hide();
     88                jQuery(".setupad-lazy-loading").show();
     89            } else if(position ==="shortcode") {
     90                jQuery(".setupad-content").hide();
     91                jQuery(".setupad-image").hide();
     92                jQuery(".setupad-shortcode").show();
     93                jQuery(".setupad-lazy-loading").hide();
    7694            }
    7795        }))
  • setupad/trunk/admin/includes/database/create-update-ad-unit.php

    r2875414 r2891046  
    1313        'setupad_content_elements' => (isset($_POST['setupad_content_elements'])) ? sanitize_text_field($_POST['setupad_content_elements']) : '',
    1414        'setupad_image_url' => (isset($_POST['setupad_image_url'])) ? sanitize_url($_POST['setupad_image_url']) : '',
     15        'setupad_shortcode_content' => (isset($_POST['setupad_shortcode_content'])) ? sanitize_text_field($_POST['setupad_shortcode_content']) : '',
    1516        'setupad_insertion_pages' => (isset($_POST['setupad_insertion_pages'])) ? sanitize_text_field($_POST['setupad_insertion_pages']) : '',
    1617        'setupad_position' => sanitize_text_field($_POST['setupad_position']),
     
    4950            $result = $wpdb->insert($table_name, $item);
    5051            $Id = $wpdb->insert_id;
    51             $shortCodeData = [ 'setupad_shortcode' => "[setup_ad num=".$Id."]" ];
     52            $shortCodeData = [ 'setupad_shortcode' => "[setupad num=".$Id."]" ];
    5253            $wpdb->update($table_name, $shortCodeData, array('id' => $Id));
    5354            if ($result) {
     
    7980                                                                    setupad_content,
    8081                                                                    setupad_content_elements,
    81                                                                     setupad_image_url,
     82                                                                    setupad_image_url,
     83                                                                    setupad_shortcode_content,
    8284                                                                    setupad_insertion_pages,
    8385                                                                    setupad_position,
  • setupad/trunk/admin/includes/database/setupad-tables-upgrade.php

    r2875414 r2891046  
    22global $wpdb;
    33$table_name = $wpdb->prefix . "setupad";
    4 $setupad_db_version = '1.0.0';
     4$setupad_db_version = '1.2.0';
    55$charset_collate = $wpdb->get_charset_collate();
    66$setupad_installed_ver = get_option( "setupad_db_version" );
     
    1515        `setupad_image_url` text NULL DEFAULT NULL,
    1616        `setupad_image_file_path` text NULL DEFAULT NULL,
     17        `setupad_shortcode_content` text NULL DEFAULT NULL,
    1718        `setupad_insertion_pages` VARCHAR(100) NULL DEFAULT NULL,
    1819        `setupad_position` VARCHAR(100) NOT NULL,
  • setupad/trunk/admin/includes/database/setupad-tables.php

    r2875414 r2891046  
    22global $wpdb;
    33$table_name = $wpdb->prefix . "setupad";
    4 $setupad_db_version = '1.0.0';
     4$setupad_db_version = '1.2.0';
    55$charset_collate = $wpdb->get_charset_collate();
    66
     
    1313            `setupad_image_url` text NULL DEFAULT NULL,
    1414            `setupad_image_file_path` text NULL DEFAULT NULL,
     15            `setupad_shortcode_content` text NULL DEFAULT NULL,
    1516            `setupad_insertion_pages` VARCHAR(100) NULL DEFAULT NULL,
    1617            `setupad_position` VARCHAR(100) NOT NULL,
  • setupad/trunk/admin/includes/forms/setupad-create-ad-unit-form.php

    r2881084 r2891046  
    4646                                <label class="single-d-label"><?php _e('Image', 'setupad')?></label>
    4747                                <input class="single-d-input" type="radio" name="setupad_type" value="images" <?php checked( $item['setupad_type'], 'images' ); ?>>
     48                            </div>
     49                            <div <?php echo ($item['setupad_position'] == 'shortcode') ? 'class="single-d-div checked"' : 'class="single-d-div"'; ?>>
     50                                <label class="single-d-label"><?php _e('Shortcode', 'setupad')?></label>
     51                                <input class="single-d-input" type="radio" name="setupad_type" value="shortcode" <?php checked( $item['setupad_type'], 'shortcode' ); ?>>
    4852                            </div>
    4953                        </div>
     
    247251        </tr>
    248252
     253        <tr class="form-field setupad-shortcode">
     254            <th scope="row">
     255                <label for="setupad_content"><?php _e('Shortcode', 'setupad')?></label>
     256            </th>
     257
     258            <td>
     259                <div class="stpd-tooltip">
     260                    <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16">
     261                        <path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
     262                    </svg>
     263                    <span class="stpd-tooltiptext">Insert any valid shortcode that you want to display on your website.</span>
     264                </div>
     265            </td>
     266
     267            <td>
     268                <input id="setupad_shortcode_content" name="setupad_shortcode_content" value="<?php if (isset($item['setupad_shortcode_content'])) echo esc_attr(stripslashes($item['setupad_shortcode_content']))?>"
     269                       size="100" class="code" placeholder="<?php _e('Shortcode, e.g., [my shortcode 5]', 'setupad')?>" AutoComplete=off data-lpignore="true" type="text" style="max-width: 600px;">
     270            </td>
     271        </tr>
     272
    249273        <tr class="form-field page-selection">
    250274            <th scope="row">
     
    802826        </tr>
    803827
    804         <tr class="form-field">
     828        <tr class="form-field setupad-lazy-loading">
    805829            <th scope="row">
    806830                <label for="setupad_title"><?php _e('Enable lazy loading', 'setupad')?></label>
  • setupad/trunk/admin/includes/navigation/admin-menu.php

    r2875414 r2891046  
    55    global $submenu;
    66
    7     add_menu_page(__('Setupad', 'setupad'), __('Setupad', 'setupad'), 'activate_plugins', 'setupad', 'setupad_my_ads_tab', SETUPAD_BASE_URL .'admin/assets/images/plugin_logo.png');
     7    add_menu_page(__('Setupad', 'setupad'), __('Setupad', 'setupad'), 'activate_plugins', 'setupad', 'setupad_my_ads_tab', 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iIzljYTFhOCI+CiAgICA8cGF0aCBzdHlsZT0ic3Ryb2tlOm5vbmU7ZmlsbC1ydWxlOmV2ZW5vZGQ7ZmlsbC1vcGFjaXR5OjEiIGQ9Ik04LjY3NiA2LjkwNmMuMDA0IDAgMi4yMzggNi4wNjcgMy4zODYgOS4wOWgyLjc0M2MuNzg1IDAgMS4zNTEtLjc0MiAxLjE0NC0xLjQ5Ni0xLjczLTQuMzc1LTUuMjI2LTEzLjExMy01LjIyNi0xMy4xMTcgMCAuMDA0LTIuMDQzIDUuNTIzLTIuMDQ3IDUuNTIzWk01LjgwNS4wMDhDMy44OTUgNC44NCAxLjk2NSA5LjY2OC4wNSAxNC41Yy0uMjExLjc1NC4zNiAxLjQ5NiAxLjE0NCAxLjQ5NkgzLjkzQzUuMjY2IDEyLjUyMyA5LjM4NyAxLjg2NyAxMC4wOTguMDA4Wm0wIDAiLz4KPC9zdmc+Cg==', 26);
    88    add_submenu_page('setupad', __('Add new', 'setupad'), __('Add new', 'setupad'), 'activate_plugins', 'stpd-new_ad', 'setupad_create_ad_unit_tab');
    99    add_submenu_page('setupad', __('Related Posts', 'setupad'), __('Related Posts', 'setupad'), 'activate_plugins', 'stpd-related-posts', 'setupad_related_posts_tab');
  • setupad/trunk/public/includes/add-setupad-shortcode.php

    r2875414 r2891046  
    1818}
    1919add_shortcode('setup_ad','setupad_ad_sc');
     20
     21function setupad_sc($atts, $content = null) {
     22    extract(shortcode_atts(array(
     23        'num' => '',
     24    ), $atts));
     25    global $wpdb;
     26    $tablename= $wpdb->prefix . 'setupad';
     27
     28    $setupad_row = $wpdb->get_row( $wpdb->prepare("SELECT * FROM %5s WHERE id = %d", $tablename, $num) );
     29
     30    if(!$setupad_row) return;
     31
     32    $adContents = setupad_get_ad_contents($setupad_row);
     33
     34    return $adContents;
     35}
     36add_shortcode('setupad','setupad_sc');
  • setupad/trunk/public/includes/helper-functions.php

    r2875414 r2891046  
    2626function setupad_get_ad_contents($ad_row) {
    2727    $adContents = '';
     28    $device_selection_array = [];
     29    if ($ad_row->setupad_device_selection) $device_selection_array = explode(',', $ad_row->setupad_device_selection);
     30
     31    //shortcode insertion
     32    if ($ad_row->setupad_type === 'shortcode') {
     33        if (in_array(setupad_server_side_mobile_detection(), $device_selection_array) || !$ad_row->setupad_device_selection) {
     34            if ($ad_row->setupad_contents_alignment && $ad_row->setupad_alignment_css) {
     35                return "<div style='". stripslashes($ad_row->setupad_alignment_css) ."'>" . do_shortcode(stripslashes($ad_row->setupad_shortcode_content)) . "</div>";
     36            } else {
     37                return do_shortcode(stripcslashes($ad_row->setupad_shortcode_content));
     38            }
     39        } else {
     40            return false;
     41        }
     42    }
    2843
    2944    json_decode(stripcslashes($ad_row->setupad_content));
     
    5469        $adContents = "<div style='". stripslashes($ad_row->setupad_alignment_css) ."'>" . $adContents . "</div>";
    5570    }
    56 
    57     $device_selection_array = [];
    58     if ($ad_row->setupad_device_selection) $device_selection_array = explode(',', $ad_row->setupad_device_selection);
    5971
    6072    if (in_array(setupad_server_side_mobile_detection(), $device_selection_array) || !$ad_row->setupad_device_selection)
  • setupad/trunk/public/includes/related-posts.php

    r2881115 r2891046  
    105105        while ( $my_query->have_posts() ) {
    106106            $my_query->the_post();
    107             $trimmed_title = strlen($post->post_title) > 35 ? substr($post->post_title,0,35)."..." : $post->post_title;
     107
     108            if (strlen($post->post_title) > 35) {
     109                $s = substr($post->post_title, 0, 35);
     110                $trimmed_title = substr($s, 0, strrpos($s, ' ')) . "...";
     111            } else {
     112                $trimmed_title = $post->post_title;
     113            }
    108114
    109115            ?>
     
    122128                $related_category_content .= "<div class=\"relatedthumb\">
    123129                                        <a href=\"" . get_permalink() . "\" rel=\"bookmark\" title=\"" . $post->post_title . "\">
    124                                             <img src=\"" . get_post_meta($post->ID, 'Image', true) . "\" width=\"196\" height=\"110\"
    125                                                  alt=\"" . $post->post_title  . "\">
    126130                                            " . $trimmed_title . "</a>
    127131                                    </div>";
  • setupad/trunk/readme.txt

    r2881115 r2891046  
    55Requires at least: 4.4
    66Tested up to: 6.1
    7 Stable tag: 1.1.2
     7Stable tag: 1.2.0
    88Requires PHP: 5.6
    99License: GPLv2 or later
     
    7878== Changelog ==
    7979
     80= 1.2.0 =
     81- Shortcode insertion
     82- Bug fixes, design changes
     83
    8084= 1.1.2 =
    8185- Bug fixes
  • setupad/trunk/setupad.php

    r2881115 r2891046  
    22/**
    33 * @package Setupad
    4  * @version 1.1.2
     4 * @version 1.2.0
    55 */
    66/*
     
    88Description: Simple and powerful ad insertion and management tool for WordPress users with built-in integration with Setupad header bidding monetization platform.
    99Author: Setupad
    10 Version: 1.1.2
     10Version: 1.2.0
    1111Author URI: https://setupad.com/
    1212*/
     
    3636            if (!isset($_GET['page'])) return;
    3737            if ($_GET['page'] ==='setupad' || $_GET['page'] ==='stpd-new_ad' || $_GET['page'] ==='stpd-ads_txt' || $_GET['page'] ==='stpd-related-posts' || $_GET['page'] ==='stpd-header-footer') {
    38                 wp_register_style('custom.css', SETUPAD_BASE_URL . 'admin/assets/css/custom.css', array(), '35.6');
     38                wp_register_style('custom.css', SETUPAD_BASE_URL . 'admin/assets/css/custom.css', array(), '35.7');
    3939                wp_enqueue_style('custom.css');
    4040
    41                 wp_register_script('setupad.js', SETUPAD_BASE_URL . 'admin/assets/js/setupad.js', array('jquery'), '25.2');
     41                wp_register_script('setupad.js', SETUPAD_BASE_URL . 'admin/assets/js/setupad.js', array('jquery'), '25.4');
    4242                wp_enqueue_script('setupad.js');
    4343
Note: See TracChangeset for help on using the changeset viewer.