Plugin Directory

Changeset 3058190


Ignore:
Timestamp:
03/25/2024 10:44:20 AM (2 years ago)
Author:
eljefe6a
Message:

Updating to Summarizes 2.0.0

Location:
summarizes/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • summarizes/trunk/readme.txt

    r2959954 r3058190  
    11=== Plugin Name ===
    22Contributors: eljefe6a, freemius
    3 Tags: ai, gpt, chatgpt, summary, summarize
     3Tags: ai, gpt, chatgpt, summary, summarize, pull quote, faq
    44Requires at least: 5.3
    55Tested up to: 6.1
    6 Stable tag: 1.0.3
     6Stable tag: 2.0.0
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    4848- Automatic summarization: The plugin uses advanced natural language processing algorithms to generate concise and accurate summaries of your content.
    4949- Customizable summaries: You can modify the generated summaries to suit your preferences and make them more engaging for your readers.
     50- FAQ creation: Automatically generate FAQs based on your existing blog content to improve user experience.
     51- Pull Quotes: Identify and extract key quotes from your blog posts to highlight them as pull quotes and increase engagement.
    5052- Easy integration: The plugin seamlessly integrates into the WordPress editor, making it effortless to generate and insert summaries into your posts and articles.
    5153- Time-saving: By using automatic summarization, you can save time and effort in creating compelling summaries, allowing you to focus on producing high-quality content.
     54
     55Update
    5256
    5357## Frequently Asked Questions
     
    7175## Changelog
    7276
     77### Version 2.0
     78- Added pull quotes (excerpt that has been pulled from an article) feature to highlight a section of the post to the Pro version.
     79- Added FAQ (excerpt that has been pulled from an article) feature to the Pro version.
     80- Backend server rewrite for faster responses.
     81
    7382### Version 1.0
    7483- Initial release of the Summariz.es WordPress Plugin.
  • summarizes/trunk/summarizes.php

    r2959954 r3058190  
    33/*
    44Plugin Name: Summarizes
    5 Description: Uses the latest cutting-edge AI to summarize your blog 
    6 Version: 1.0.4
     5Description: Uses the latest cutting-edge AI to summarize your blog, add pull quotes, and create FAQs.
     6Version: 2.0.0
    77Author: Big Data Institute International Ltd
    88License:     GPLv2
     
    8282           
    8383            if ( $post_summary_array != '' ) {
     84               
     85                if ( summarizes_fs()->can_use_premium_code() ) {
     86                    $content = summarizes_add_pull_quote_to_post__premium_only( $content );
     87                    $content = summarizes_add_faq_to_post__premium_only( $content );
     88                }
     89               
    8490                // Reduce number of summaries to what user wants or fewer
    8591                $number_of_summaries = get_option( 'summarizes_number_of_summaries', 1 );
    8692                $post_summary_array = array_slice( $post_summary_array, 0, $number_of_summaries );
    8793                summarizes_log( "summarizes_add_summary_to_post post_summary_array\"" . summarizes_implode_recursive( $post_summary_array ) . "\"", false );
    88                 // TODO: Add blurb about summary coming from plugin with link?
    8994                $content = summarizes_format_summary( $summary_title, $post_summary_array ) . $content;
    9095            }
     
    98103}
    99104
     105if ( !function_exists( 'summarizes_add_pull_quote_to_post__premium_only' ) ) {
     106}
     107if ( !function_exists( 'summarizes_add_faq_to_post__premium_only' ) ) {
     108}
     109if ( !function_exists( 'summarizes_find_pull_quote_location__premium_only' ) ) {
     110}
    100111
    101112if ( !function_exists( 'summarizes_options_page' ) ) {
     
    115126}
    116127
    117 if ( !function_exists( 'summarizes_handle_premium_settings__premium_only' ) ) {
    118 }
    119 if ( !function_exists( 'summarizes_options_page_content' ) ) {
    120     // Define the content of the options page.
    121     function summarizes_options_page_content()
    122     {
    123         // If the form has been submitted, save the options.
     128if ( !function_exists( 'summarizes_handle_free_settings' ) ) {
     129    function summarizes_handle_free_settings()
     130    {
    124131       
    125132        if ( isset( $_POST['summary_title'] ) && isset( $_POST['html_id'] ) && isset( $_POST['html_css'] ) ) {
     
    160167            echo  '<div class="notice notice-success"><p>Options updated.</p></div>' ;
    161168        }
     169   
     170    }
     171
     172}
     173if ( !function_exists( 'summarizes_handle_premium_settings__premium_only' ) ) {
     174}
     175if ( !function_exists( 'summarizes_handle_premium_pull_quote_settings__premium_only' ) ) {
     176}
     177if ( !function_exists( 'summarizes_handle_premium_faq_settings__premium_only' ) ) {
     178}
     179if ( !function_exists( 'summarizes_options_page_content' ) ) {
     180    // Define the content of the options page.
     181    function summarizes_options_page_content()
     182    {
     183        // If the form has been submitted, save the options.
     184        summarizes_handle_free_settings();
    162185       
    163186        if ( summarizes_fs()->can_use_premium_code() ) {
    164187            summarizes_handle_premium_settings__premium_only();
    165         }
     188            summarizes_handle_premium_pull_quote_settings__premium_only();
     189            summarizes_handle_premium_faq_settings__premium_only();
     190        }
     191       
    166192        // Retrieve the current options.
    167193        $html_id = get_option( 'summarizes_html_id', 'summarizes_summary_id' );
     
    175201        $summary_title = get_option( 'summarizes_summary_title', 'Blog Summary:' );
    176202        $tier = summarizes_get_tier();
     203        $pull_quote_enable = get_option( 'summarizes_pull_quote_enable', true );
     204        $pull_quote_number_per_page = get_option( 'summarizes_pull_quote_number_per_page', 2 );
     205        $pull_quote_begin_html = get_option( 'summarizes_pull_quote_begin_html', '<blockquote class="right quote">' );
     206        $pull_quote_end_html = get_option( 'summarizes_pull_quote_end_html', '</blockquote>' );
     207        $pull_quote_skip_existing = get_option( 'summarizes_pull_quote_skip_existing', true );
     208        $faq_enable = get_option( 'summarizes_faq_enable', true );
     209        $faq_title = get_option( 'summarizes_faq_title', 'Frequently Asked Questions' );
     210        $faq_html_id = get_option( 'summarizes_faq_html_id', 'summarizes_faq_id' );
     211        $faq_html_css = get_option( 'summarizes_faq_html_css', 'summarizes_faq_css' );
    177212        summarizes_log( "Current settings batch_size=\"{$batch_size}\" number_of_summaries=\"{$number_of_summaries}\" tier=\"" . $tier . "\" license=\"" . summarizes_get_license() . "\" summary_type=\"{$summary_type}\" summary_title=\"{$summary_title}\" html_id=\"{$html_id}\" html_css=\"{$html_css}\" debug_mode=\"{$debug_mode}\" disclose_ai=\"{$disclose_ai}\"", false );
    178213        $tab = ( isset( $_GET['tab'] ) ? sanitize_html_class( $_GET['tab'] ) : "freesettings" );
    179214        // TODO: Add debug output tab
    180         // TODO: Add checkbox for allowing credit and say may be legally required
    181215        // Display the options form.
    182216        summarizes_show_tab_options( $tab );
     
    202236            $disclose_ai
    203237        );
     238       
    204239        if ( summarizes_fs()->can_use_premium_code() ) {
    205240            summarizes_show_pro_settings__premium_only(
     
    210245                $summary_type
    211246            );
    212         }
     247            summarizes_show_pro_pull_quote_settings__premium_only(
     248                $tab,
     249                $pull_quote_enable,
     250                $pull_quote_number_per_page,
     251                $pull_quote_begin_html,
     252                $pull_quote_end_html,
     253                $pull_quote_skip_existing
     254            );
     255            summarizes_show_pro_faq_settings__premium_only(
     256                $tab,
     257                $faq_enable,
     258                $faq_title,
     259                $faq_html_id,
     260                $faq_html_css
     261            );
     262        }
     263   
    213264    }
    214265
     
    251302                    <ul style="list-style: '✓  ' outside none;">
    252303                        <li><strong>Configurable number of sentences of summarization</strong> - You choose the maximum number of sentences for your summary.</li>
    253                         <li><strong>Bulk Summarization</strong> - Bulk summarization to summarize all blog posts for site</li>
    254                         <li><strong>Summarization Styles</strong> - Different styles of summarization that you can choose</li>
    255                         <li><strong>Bulk Re-Summarize for Better AI Models</strong> - Bulk re-summarization as newer and better models come out</li>
    256                         <li><strong>Summarize Multiple Sites</strong> - Buy the multi-site license and summarize your content on several sites.</li>
    257 
     304                        <li><strong>Bulk Summarization</strong> - Bulk summarization to summarize all blog posts for your site.</li>
     305                        <li><strong>FAQ creation</strong> - Automatically generate FAQs from your blog content.</li>
     306                        <li><strong>Pull Quotes</strong> - Identify and extract quotes from the blog to highlight as pull quotes.</li>
     307                        <li><strong>Summarization Styles</strong> - Choose from different styles of summarization to tailor the output to your needs.</li>
     308                        <li><strong>Bulk Re-Summarize for Better AI Models</strong> - As newer and better AI models become available, you can easily bulk re-summarize your content to leverage their capabilities.</li>
     309                        <li><strong>Summarize Multiple Sites</strong> - Purchase the multi-site license to summarize content across several of your websites.</li>
    258310                    </ul>
    259311                    <form action="https://checkout.freemius.com/mode/dialog/plugin/12317/plan/20924/">
     
    345397                </table>
    346398
    347                 <p>We are not affiliated with Confluent in any way. This is an example taken from a long-form post about Confluent.</p>
     399                <p><strong>We are not affiliated with Confluent in any way. This is an example taken from a long-form post about Confluent.</strong></p>
    348400
    349401            <?php
     
    414466if ( !function_exists( 'summarizes_show_pro_settings__premium_only' ) ) {
    415467}
     468if ( !function_exists( 'summarizes_show_pro_pull_quote_settings__premium_only' ) ) {
     469}
     470if ( !function_exists( 'summarizes_show_pro_faq_settings__premium_only' ) ) {
     471}
    416472
    417473if ( !function_exists( 'summarize_single_post' ) ) {
     
    429485            // Add the new post to the list to summarize
    430486            array_push( $posts_to_summarize, $post_array );
    431             $posts_to_summarize = summarizes_prepare_arrays_for_summary( $posts_to_summarize );
     487            $posts_to_summarize = summarizes_prepare_arrays_for_summary( $posts_to_summarize, [ $the_post ], true );
    432488            summarizes_add_summary_to_post_meta( $the_post, $posts_to_summarize );
    433489            summarizes_log( "resummarize_updated_post post_ID=\"" . $post_ID . "\"", false );
     
    516572    // Prepares posts for summary, adds license information,
    517573    // and calls the REST interface
    518     function summarizes_prepare_arrays_for_summary( array $post_array ) : array
     574    function summarizes_prepare_arrays_for_summary( array $post_array, array $posts, bool $force ) : array
    519575    {
    520576        $license_array = [
     
    525581            "summarytype" => summarizes_get_summary_type(),
    526582        ];
     583       
     584        if ( summarizes_fs()->can_use_premium_code() ) {
     585            $hasAllSummaries = !$force;
     586            $hasAllFAQs = !$force;
     587            $hasAllPullQuotes = !$force;
     588            // Check if each post has all of information in it already
     589            if ( $force == false ) {
     590                foreach ( $posts as $post ) {
     591                    $post_summary_array = get_post_meta( get_post()->ID, "summarizes_summary", true );
     592                    $summarizes_faq_array = get_post_meta( get_post()->ID, "summarizes_faq", true );
     593                    $summarizes_pull_quote_array = get_post_meta( get_post()->ID, "summarizes_pull_quote", true );
     594                    if ( $post_summary_array == "" ) {
     595                        $hasAllSummaries = false;
     596                    }
     597                    if ( $summarizes_faq_array == "" ) {
     598                        $hasAllFAQs = false;
     599                    }
     600                    if ( $summarizes_pull_quote_array == "" ) {
     601                        $hasAllPullQuotes = false;
     602                    }
     603                }
     604            }
     605            // Check if summary is already done
     606            if ( $hasAllSummaries == true ) {
     607                unset( $options_array['summarytype'] );
     608            }
     609            // Add faq and quotes if enabled and missing
     610            if ( get_option( 'summarizes_faq_enable', true ) && $hasAllFAQs == false ) {
     611                $options_array["faq"] = true;
     612            }
     613           
     614            if ( get_option( 'summarizes_pull_quote_enable', true ) && $hasAllPullQuotes == false ) {
     615                $options_array["quotes"] = true;
     616                // Check if it should skip the posts with block quotes already
     617                $pull_quote_skip_existing = get_option( 'summarizes_pull_quote_skip_existing', true );
     618               
     619                if ( $pull_quote_skip_existing == true ) {
     620                    // Check if the pull quote begin html is in the post
     621                    $summarizes_pull_quote_begin_html = get_option( 'summarizes_pull_quote_begin_html', '<blockquote class="right quote">' );
     622                    foreach ( $post_list as $post_array ) {
     623                       
     624                        if ( str_contains( $post_list, $summarizes_pull_quote_begin_html ) ) {
     625                            // Begin html found. Skip it.
     626                            $options_array["quotes"] = false;
     627                            summarizes_log( "skipping creating pull quotes as begin html is in it", false );
     628                            break;
     629                        }
     630                   
     631                    }
     632                }
     633           
     634            }
     635       
     636        }
     637       
    527638        $summary_array = [
    528639            "posts"   => $post_array,
     
    541652    {
    542653        $permalink = get_the_permalink( $the_post );
    543         $post_summary_array = $posts_to_summarize["summarydetails"][$permalink]["summaryresult"];
    544         $post_method = $posts_to_summarize["summarydetails"][$permalink]["summarymethod"];
    545654        // Verify there wasn't an issue finding the post's summary
    546655       
    547         if ( $post_summary_array == null || $post_method == null ) {
     656        if ( array_key_exists( $permalink, $posts_to_summarize["summarydetails"] ) == false ) {
    548657            // There was an error with finding the page's summary
    549             // Log and return
    550658            summarizes_log( "summarizes_add_summary_to_post_meta could not find permalink {$permalink} in posts_to_summarize=\"" . summarizes_implode_recursive( $posts_to_summarize ) . "\"", false );
    551659        } else {
    552             $worked1 = update_post_meta( $the_post->ID, "summarizes_summary", $post_summary_array );
    553             $worked2 = update_post_meta( $the_post->ID, "summarizes_method", $post_method );
    554             summarizes_log( "summarizes_add_summary_to_post_meta post_summary_array=\"" . summarizes_implode_recursive( $post_summary_array ) . "\" worked1=\"" . summarizes_bool_to_string( $worked1 ) . "\" worked2=\"" . summarizes_bool_to_string( $worked2 ) . "\"", false );
     660           
     661            if ( array_key_exists( 'summaryresult', $posts_to_summarize["summarydetails"][$permalink] ) ) {
     662                // Add the summary to the post
     663                $post_summary_array = $posts_to_summarize["summarydetails"][$permalink]["summaryresult"];
     664                $post_method = $posts_to_summarize["summarydetails"][$permalink]["summarymethod"];
     665                $worked1 = update_post_meta( $the_post->ID, "summarizes_summary", $post_summary_array );
     666                $worked2 = update_post_meta( $the_post->ID, "summarizes_method", $post_method );
     667                summarizes_log( "summarizes_add_summary_to_post_meta post_summary_array=\"" . summarizes_implode_recursive( $post_summary_array ) . "\" worked1=\"" . summarizes_bool_to_string( $worked1 ) . "\" worked2=\"" . summarizes_bool_to_string( $worked2 ) . "\"", false );
     668            }
     669           
     670           
     671            if ( summarizes_fs()->can_use_premium_code() ) {
     672               
     673                if ( array_key_exists( 'quotesresult', $posts_to_summarize["summarydetails"][$permalink] ) ) {
     674                    // Add the pull quotes to the post
     675                    $quotes_array = $posts_to_summarize["summarydetails"][$permalink]['quotesresult'];
     676                    $worked1 = update_post_meta( $the_post->ID, "summarizes_pull_quote", $quotes_array );
     677                    summarizes_log( "summarizes_add_summary_to_post_meta quotes_array=\"" . summarizes_implode_recursive( $quotes_array ) . "\" worked1=\"" . summarizes_bool_to_string( $worked1 ) . "\"", false );
     678                }
     679               
     680               
     681                if ( array_key_exists( 'faqresult', $posts_to_summarize["summarydetails"][$permalink] ) ) {
     682                    // Add the faq to the post
     683                    $faq_array = $posts_to_summarize["summarydetails"][$permalink]['faqresult'];
     684                    $worked1 = update_post_meta( $the_post->ID, "summarizes_faq", $faq_array );
     685                    summarizes_log( "summarizes_add_summary_to_post_meta faq_array=\"" . summarizes_implode_recursive( $faq_array ) . "\" worked1=\"" . summarizes_bool_to_string( $worked1 ) . "\"", false );
     686                }
     687           
     688            }
     689       
    555690        }
    556691   
     
    560695if ( !function_exists( 'summarizes_implode_recursive' ) ) {
    561696    // Implodes an array into JSON string
    562     function summarizes_implode_recursive( array $array ) : string
    563     {
    564         return wp_json_encode( $array );
     697    function summarizes_implode_recursive( $array ) : string
     698    {
     699       
     700        if ( is_string( $array ) ) {
     701            return $array;
     702        } else {
     703            return wp_json_encode( $array );
     704        }
     705   
    565706    }
    566707
     
    583724       
    584725        if ( summarizes_fs()->can_use_premium_code() ) {
    585             return summarizes_check_pro_better_summary_exists__premium_only( $tier, $summarizes_method );
     726            if ( summarizes_check_pro_better_summary_exists__premium_only( $tier, $summarizes_method ) == false ) {
     727                if ( summarizes_check_faq_and_pull_quote_exist__premium_only( $the_post ) == true ) {
     728                    // Summary there but missing faq or pull quote
     729                    return true;
     730                }
     731            }
     732            return false;
    586733        } else {
    587734            return false;
     
    592739}
    593740if ( !function_exists( 'summarizes_check_pro_better_summary_exists__premium_only' ) ) {
     741}
     742if ( !function_exists( 'summarizes_check_faq_and_pull_quote_exist__premium_only' ) ) {
    594743}
    595744if ( !function_exists( 'summarizes_call_summarizer' ) ) {
Note: See TracChangeset for help on using the changeset viewer.