Plugin Directory

Changeset 3843836


Ignore:
Timestamp:
12/04/2026 06:44:33 AM (2 days ago)
Author:
autoposterai
Message:

1.1.0: widget block, shortcode, floating widget; screenshots

Location:
auto-poster-ai
Files:
12 added
6 edited
4 copied

Legend:

Unmodified
Added
Removed
  • auto-poster-ai/assets/banner-1544x500.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • auto-poster-ai/assets/banner-772x250.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • auto-poster-ai/assets/icon-128x128.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • auto-poster-ai/assets/icon-256x256.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • auto-poster-ai/tags/1.1.0/auto-poster-ai.php

    r3841390 r3843836  
    33 * Plugin Name:       Auto Poster AI – Share Posts to Social Media
    44 * Plugin URI:        https://autoposter.ai/wordpress
    5  * Description:       Automatically share new posts to your social media accounts through Auto Poster AI.
    6  * Version:           1.0.0
    7  * Requires at least: 6.2
     5 * Description:       Automatically share new posts to your social media accounts and embed Auto Poster AI social feed widgets.
     6 * Version:           1.1.0
     7 * Requires at least: 6.3
    88 * Requires PHP:      7.4
    99 * Author:            Auto Poster AI
    … …  
    3333                        'post_types'  => array( 'post' ),
    3434                        'template'    => "{title}\n\n{url}",
     35                        'floating'    => '',
    3536                )
    3637        );
    … …  
    117118                        false
    118119                );
     120        }
     121}
     122
     123/* ---------- Website widgets ---------- */
     124
     125const AUTOPOSTERAI_WIDGET_HOST_DEFAULT = 'https://cdn.autoposter.ai';
     126
     127// Override with the AUTOPOSTERAI_WIDGET_HOST constant or the autoposterai_widget_host filter (staging, dev).
     128function autoposterai_widget_host() {
     129        $host = defined( 'AUTOPOSTERAI_WIDGET_HOST' ) ? AUTOPOSTERAI_WIDGET_HOST : AUTOPOSTERAI_WIDGET_HOST_DEFAULT;
     130        return untrailingslashit( apply_filters( 'autoposterai_widget_host', $host ) );
     131}
     132
     133function autoposterai_widget_id( $id ) {
     134        return preg_replace( '/[^A-Za-z0-9_-]/', '', (string) $id );
     135}
     136
     137function autoposterai_enqueue_embed() {
     138        wp_enqueue_script(
     139                'autoposterai-embed',
     140                autoposterai_widget_host() . '/widgets/v1/embed.js',
     141                array(),
     142                null, // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- the CDN file is versioned by its /v1/ path.
     143                array(
     144                        'in_footer' => true,
     145                        'strategy'  => 'async',
     146                )
     147        );
     148}
     149
     150// embed.js reads its host and the floating widget from its own script tag.
     151add_filter( 'script_loader_tag', 'autoposterai_embed_tag', 10, 2 );
     152function autoposterai_embed_tag( $tag, $handle ) {
     153        if ( 'autoposterai-embed' !== $handle ) {
     154                return $tag;
     155        }
     156        $attrs    = '';
     157        $host     = autoposterai_widget_host();
     158        $floating = autoposterai_widget_id( autoposterai_settings()['floating'] );
     159        if ( AUTOPOSTERAI_WIDGET_HOST_DEFAULT !== $host ) {
     160                $attrs .= ' data-apai-cdn="' . esc_attr( $host ) . '"';
     161        }
     162        if ( $floating ) {
     163                $attrs .= ' data-apai-floating="' . esc_attr( $floating ) . '"';
     164        }
     165        return $attrs ? preg_replace( '/<script\b/', '<script' . $attrs, $tag, 1 ) : $tag;
     166}
     167
     168add_shortcode( 'autoposter_widget', 'autoposterai_widget_shortcode' );
     169function autoposterai_widget_shortcode( $atts ) {
     170        $atts = shortcode_atts( array( 'id' => '' ), $atts, 'autoposter_widget' );
     171        $id   = autoposterai_widget_id( $atts['id'] );
     172        if ( ! $id ) {
     173                return '';
     174        }
     175        autoposterai_enqueue_embed();
     176        return '<div data-apai-widget="' . esc_attr( $id ) . '"></div>';
     177}
     178
     179add_action( 'init', 'autoposterai_register_block' );
     180function autoposterai_register_block() {
     181        register_block_type(
     182                __DIR__ . '/block',
     183                array(
     184                        'render_callback' => static function ( $attributes ) {
     185                                return autoposterai_widget_shortcode( array( 'id' => isset( $attributes['widgetId'] ) ? $attributes['widgetId'] : '' ) );
     186                        },
     187                )
     188        );
     189}
     190
     191add_action( 'wp_enqueue_scripts', 'autoposterai_enqueue_floating' );
     192function autoposterai_enqueue_floating() {
     193        if ( autoposterai_settings()['floating'] ) {
     194                autoposterai_enqueue_embed();
    119195        }
    120196}
    … …  
    258334                'post_types'  => array_values( array_filter( $list( 'post_types' ), 'post_type_exists' ) ),
    259335                'template'    => isset( $input['template'] ) ? sanitize_textarea_field( $input['template'] ) : '',
     336                'floating'    => isset( $input['floating'] ) ? autoposterai_widget_id( $input['floating'] ) : '',
    260337        );
    261338}
    … …  
    373450                                        </td>
    374451                                </tr>
     452                                <tr>
     453                                        <th scope="row"><label for="autoposterai-floating"><?php esc_html_e( 'Floating widget ID', 'auto-poster-ai' ); ?></label></th>
     454                                        <td>
     455                                                <input id="autoposterai-floating" type="text" class="regular-text" placeholder="wgt_..." name="<?php echo esc_attr( $name ); ?>[floating]" value="<?php echo esc_attr( $settings['floating'] ); ?>">
     456                                                <p class="description"><?php esc_html_e( 'Optional. Shows a floating widget, such as a chat button, on every page of your site. To place a feed inside a page, use the Auto Poster AI widget block or the [autoposter_widget id="wgt_..."] shortcode.', 'auto-poster-ai' ); ?></p>
     457                                        </td>
     458                                </tr>
    375459                        </table>
    376460                        <?php submit_button(); ?>
  • auto-poster-ai/tags/1.1.0/readme.txt

    r3841390 r3843836  
    22Contributors: autoposterai
    33Tags: social media, auto post, share, scheduler, social sharing
    4 Requires at least: 6.2
     4Requires at least: 6.3
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Automatically share new posts to your social media accounts through Auto Poster AI.
     11Automatically share new posts to your social media accounts and embed social feed widgets from Auto Poster AI.
    1212
    1313== Description ==
    … …  
    2323
    2424An Auto Poster AI account on a paid plan is required.
     25
     26= Website widgets =
     27
     28Show your social posts on your site with Auto Poster AI widgets. Create a widget in Auto Poster AI (Widgets), copy its ID, then:
     29
     30* Add the **Auto Poster AI widget** block and paste the widget ID, or
     31* Use the shortcode `[autoposter_widget id="wgt_..."]` anywhere shortcodes work.
     32* For a floating widget, such as a chat button, on every page, enter its ID under Settings → Auto Poster AI → Floating widget ID.
     33
     34Layout, theme and the "Powered by" badge are set in the widget's own settings in Auto Poster AI.
    2535
    2636== Installation ==
    … …  
    4757No. Only posts published after the plugin is set up.
    4858
     59= Do widgets need the API connection? =
     60
     61No. The block and shortcode only need the widget ID; the widget's posts are loaded from Auto Poster AI in the visitor's browser.
     62
    4963= Why is the image missing? =
    5064
    5165The featured image must be reachable from the internet. Images on local or password-protected sites cannot be fetched.
     66
     67== Screenshots ==
     68
     691. Share settings: pick the accounts and the message for new posts.
     702. A social feed widget on a page.
     713. A reviews widget with Google and Facebook reviews.
     724. The Auto Poster AI widget block in the editor.
    5273
    5374== External services ==
    … …  
    5980* When a post of a selected content type is published, your API key, the post title, excerpt, permalink and featured image URL are sent to create the social post.
    6081
    61 No data is sent until you click Connect or save an API key. The service is provided by Auto Poster AI: [Terms of Service](https://autoposter.ai/terms), [Privacy Policy](https://autoposter.ai/privacy).
     82Website widgets: when a page contains the Auto Poster AI widget block or the `[autoposter_widget]` shortcode, or a floating widget ID is set, the visitor's browser loads the widget script from https://cdn.autoposter.ai and the widget's posts from Auto Poster AI. The widget ID, the page's domain and anonymous view and click counts are sent to Auto Poster AI. No cookies are set.
     83
     84No data is sent from WordPress until you click Connect or save an API key, and no widget script is loaded until you add a widget. The service is provided by Auto Poster AI: [Terms of Service](https://autoposter.ai/terms), [Privacy Policy](https://autoposter.ai/privacy).
    6285
    6386== Changelog ==
    6487
     88= 1.1.0 =
     89* New: Auto Poster AI widget block and `[autoposter_widget id="..."]` shortcode to embed social feed widgets.
     90* New: optional floating widget on every page.
     91* Requires WordPress 6.3 or later.
     92
    6593= 1.0.0 =
    6694* Initial release.
  • auto-poster-ai/trunk/auto-poster-ai.php

    r3841390 r3843836  
    33 * Plugin Name:       Auto Poster AI – Share Posts to Social Media
    44 * Plugin URI:        https://autoposter.ai/wordpress
    5  * Description:       Automatically share new posts to your social media accounts through Auto Poster AI.
    6  * Version:           1.0.0
    7  * Requires at least: 6.2
     5 * Description:       Automatically share new posts to your social media accounts and embed Auto Poster AI social feed widgets.
     6 * Version:           1.1.0
     7 * Requires at least: 6.3
    88 * Requires PHP:      7.4
    99 * Author:            Auto Poster AI
    … …  
    3333                        'post_types'  => array( 'post' ),
    3434                        'template'    => "{title}\n\n{url}",
     35                        'floating'    => '',
    3536                )
    3637        );
    … …  
    117118                        false
    118119                );
     120        }
     121}
     122
     123/* ---------- Website widgets ---------- */
     124
     125const AUTOPOSTERAI_WIDGET_HOST_DEFAULT = 'https://cdn.autoposter.ai';
     126
     127// Override with the AUTOPOSTERAI_WIDGET_HOST constant or the autoposterai_widget_host filter (staging, dev).
     128function autoposterai_widget_host() {
     129        $host = defined( 'AUTOPOSTERAI_WIDGET_HOST' ) ? AUTOPOSTERAI_WIDGET_HOST : AUTOPOSTERAI_WIDGET_HOST_DEFAULT;
     130        return untrailingslashit( apply_filters( 'autoposterai_widget_host', $host ) );
     131}
     132
     133function autoposterai_widget_id( $id ) {
     134        return preg_replace( '/[^A-Za-z0-9_-]/', '', (string) $id );
     135}
     136
     137function autoposterai_enqueue_embed() {
     138        wp_enqueue_script(
     139                'autoposterai-embed',
     140                autoposterai_widget_host() . '/widgets/v1/embed.js',
     141                array(),
     142                null, // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- the CDN file is versioned by its /v1/ path.
     143                array(
     144                        'in_footer' => true,
     145                        'strategy'  => 'async',
     146                )
     147        );
     148}
     149
     150// embed.js reads its host and the floating widget from its own script tag.
     151add_filter( 'script_loader_tag', 'autoposterai_embed_tag', 10, 2 );
     152function autoposterai_embed_tag( $tag, $handle ) {
     153        if ( 'autoposterai-embed' !== $handle ) {
     154                return $tag;
     155        }
     156        $attrs    = '';
     157        $host     = autoposterai_widget_host();
     158        $floating = autoposterai_widget_id( autoposterai_settings()['floating'] );
     159        if ( AUTOPOSTERAI_WIDGET_HOST_DEFAULT !== $host ) {
     160                $attrs .= ' data-apai-cdn="' . esc_attr( $host ) . '"';
     161        }
     162        if ( $floating ) {
     163                $attrs .= ' data-apai-floating="' . esc_attr( $floating ) . '"';
     164        }
     165        return $attrs ? preg_replace( '/<script\b/', '<script' . $attrs, $tag, 1 ) : $tag;
     166}
     167
     168add_shortcode( 'autoposter_widget', 'autoposterai_widget_shortcode' );
     169function autoposterai_widget_shortcode( $atts ) {
     170        $atts = shortcode_atts( array( 'id' => '' ), $atts, 'autoposter_widget' );
     171        $id   = autoposterai_widget_id( $atts['id'] );
     172        if ( ! $id ) {
     173                return '';
     174        }
     175        autoposterai_enqueue_embed();
     176        return '<div data-apai-widget="' . esc_attr( $id ) . '"></div>';
     177}
     178
     179add_action( 'init', 'autoposterai_register_block' );
     180function autoposterai_register_block() {
     181        register_block_type(
     182                __DIR__ . '/block',
     183                array(
     184                        'render_callback' => static function ( $attributes ) {
     185                                return autoposterai_widget_shortcode( array( 'id' => isset( $attributes['widgetId'] ) ? $attributes['widgetId'] : '' ) );
     186                        },
     187                )
     188        );
     189}
     190
     191add_action( 'wp_enqueue_scripts', 'autoposterai_enqueue_floating' );
     192function autoposterai_enqueue_floating() {
     193        if ( autoposterai_settings()['floating'] ) {
     194                autoposterai_enqueue_embed();
    119195        }
    120196}
    … …  
    258334                'post_types'  => array_values( array_filter( $list( 'post_types' ), 'post_type_exists' ) ),
    259335                'template'    => isset( $input['template'] ) ? sanitize_textarea_field( $input['template'] ) : '',
     336                'floating'    => isset( $input['floating'] ) ? autoposterai_widget_id( $input['floating'] ) : '',
    260337        );
    261338}
    … …  
    373450                                        </td>
    374451                                </tr>
     452                                <tr>
     453                                        <th scope="row"><label for="autoposterai-floating"><?php esc_html_e( 'Floating widget ID', 'auto-poster-ai' ); ?></label></th>
     454                                        <td>
     455                                                <input id="autoposterai-floating" type="text" class="regular-text" placeholder="wgt_..." name="<?php echo esc_attr( $name ); ?>[floating]" value="<?php echo esc_attr( $settings['floating'] ); ?>">
     456                                                <p class="description"><?php esc_html_e( 'Optional. Shows a floating widget, such as a chat button, on every page of your site. To place a feed inside a page, use the Auto Poster AI widget block or the [autoposter_widget id="wgt_..."] shortcode.', 'auto-poster-ai' ); ?></p>
     457                                        </td>
     458                                </tr>
    375459                        </table>
    376460                        <?php submit_button(); ?>
  • auto-poster-ai/trunk/readme.txt

    r3841390 r3843836  
    22Contributors: autoposterai
    33Tags: social media, auto post, share, scheduler, social sharing
    4 Requires at least: 6.2
     4Requires at least: 6.3
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Automatically share new posts to your social media accounts through Auto Poster AI.
     11Automatically share new posts to your social media accounts and embed social feed widgets from Auto Poster AI.
    1212
    1313== Description ==
    … …  
    2323
    2424An Auto Poster AI account on a paid plan is required.
     25
     26= Website widgets =
     27
     28Show your social posts on your site with Auto Poster AI widgets. Create a widget in Auto Poster AI (Widgets), copy its ID, then:
     29
     30* Add the **Auto Poster AI widget** block and paste the widget ID, or
     31* Use the shortcode `[autoposter_widget id="wgt_..."]` anywhere shortcodes work.
     32* For a floating widget, such as a chat button, on every page, enter its ID under Settings → Auto Poster AI → Floating widget ID.
     33
     34Layout, theme and the "Powered by" badge are set in the widget's own settings in Auto Poster AI.
    2535
    2636== Installation ==
    … …  
    4757No. Only posts published after the plugin is set up.
    4858
     59= Do widgets need the API connection? =
     60
     61No. The block and shortcode only need the widget ID; the widget's posts are loaded from Auto Poster AI in the visitor's browser.
     62
    4963= Why is the image missing? =
    5064
    5165The featured image must be reachable from the internet. Images on local or password-protected sites cannot be fetched.
     66
     67== Screenshots ==
     68
     691. Share settings: pick the accounts and the message for new posts.
     702. A social feed widget on a page.
     713. A reviews widget with Google and Facebook reviews.
     724. The Auto Poster AI widget block in the editor.
    5273
    5374== External services ==
    … …  
    5980* When a post of a selected content type is published, your API key, the post title, excerpt, permalink and featured image URL are sent to create the social post.
    6081
    61 No data is sent until you click Connect or save an API key. The service is provided by Auto Poster AI: [Terms of Service](https://autoposter.ai/terms), [Privacy Policy](https://autoposter.ai/privacy).
     82Website widgets: when a page contains the Auto Poster AI widget block or the `[autoposter_widget]` shortcode, or a floating widget ID is set, the visitor's browser loads the widget script from https://cdn.autoposter.ai and the widget's posts from Auto Poster AI. The widget ID, the page's domain and anonymous view and click counts are sent to Auto Poster AI. No cookies are set.
     83
     84No data is sent from WordPress until you click Connect or save an API key, and no widget script is loaded until you add a widget. The service is provided by Auto Poster AI: [Terms of Service](https://autoposter.ai/terms), [Privacy Policy](https://autoposter.ai/privacy).
    6285
    6386== Changelog ==
    6487
     88= 1.1.0 =
     89* New: Auto Poster AI widget block and `[autoposter_widget id="..."]` shortcode to embed social feed widgets.
     90* New: optional floating widget on every page.
     91* Requires WordPress 6.3 or later.
     92
    6593= 1.0.0 =
    6694* Initial release.
Note: See TracChangeset for help on using the changeset viewer.