Changeset 3058190
- Timestamp:
- 03/25/2024 10:44:20 AM (2 years ago)
- Location:
- summarizes/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
summarizes.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
summarizes/trunk/readme.txt
r2959954 r3058190 1 1 === Plugin Name === 2 2 Contributors: eljefe6a, freemius 3 Tags: ai, gpt, chatgpt, summary, summarize 3 Tags: ai, gpt, chatgpt, summary, summarize, pull quote, faq 4 4 Requires at least: 5.3 5 5 Tested up to: 6.1 6 Stable tag: 1.0.36 Stable tag: 2.0.0 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 48 48 - Automatic summarization: The plugin uses advanced natural language processing algorithms to generate concise and accurate summaries of your content. 49 49 - 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. 50 52 - Easy integration: The plugin seamlessly integrates into the WordPress editor, making it effortless to generate and insert summaries into your posts and articles. 51 53 - 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 55 Update 52 56 53 57 ## Frequently Asked Questions … … 71 75 ## Changelog 72 76 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 73 82 ### Version 1.0 74 83 - Initial release of the Summariz.es WordPress Plugin. -
summarizes/trunk/summarizes.php
r2959954 r3058190 3 3 /* 4 4 Plugin Name: Summarizes 5 Description: Uses the latest cutting-edge AI to summarize your blog 6 Version: 1.0.45 Description: Uses the latest cutting-edge AI to summarize your blog, add pull quotes, and create FAQs. 6 Version: 2.0.0 7 7 Author: Big Data Institute International Ltd 8 8 License: GPLv2 … … 82 82 83 83 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 84 90 // Reduce number of summaries to what user wants or fewer 85 91 $number_of_summaries = get_option( 'summarizes_number_of_summaries', 1 ); 86 92 $post_summary_array = array_slice( $post_summary_array, 0, $number_of_summaries ); 87 93 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?89 94 $content = summarizes_format_summary( $summary_title, $post_summary_array ) . $content; 90 95 } … … 98 103 } 99 104 105 if ( !function_exists( 'summarizes_add_pull_quote_to_post__premium_only' ) ) { 106 } 107 if ( !function_exists( 'summarizes_add_faq_to_post__premium_only' ) ) { 108 } 109 if ( !function_exists( 'summarizes_find_pull_quote_location__premium_only' ) ) { 110 } 100 111 101 112 if ( !function_exists( 'summarizes_options_page' ) ) { … … 115 126 } 116 127 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. 128 if ( !function_exists( 'summarizes_handle_free_settings' ) ) { 129 function summarizes_handle_free_settings() 130 { 124 131 125 132 if ( isset( $_POST['summary_title'] ) && isset( $_POST['html_id'] ) && isset( $_POST['html_css'] ) ) { … … 160 167 echo '<div class="notice notice-success"><p>Options updated.</p></div>' ; 161 168 } 169 170 } 171 172 } 173 if ( !function_exists( 'summarizes_handle_premium_settings__premium_only' ) ) { 174 } 175 if ( !function_exists( 'summarizes_handle_premium_pull_quote_settings__premium_only' ) ) { 176 } 177 if ( !function_exists( 'summarizes_handle_premium_faq_settings__premium_only' ) ) { 178 } 179 if ( !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(); 162 185 163 186 if ( summarizes_fs()->can_use_premium_code() ) { 164 187 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 166 192 // Retrieve the current options. 167 193 $html_id = get_option( 'summarizes_html_id', 'summarizes_summary_id' ); … … 175 201 $summary_title = get_option( 'summarizes_summary_title', 'Blog Summary:' ); 176 202 $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' ); 177 212 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 ); 178 213 $tab = ( isset( $_GET['tab'] ) ? sanitize_html_class( $_GET['tab'] ) : "freesettings" ); 179 214 // TODO: Add debug output tab 180 // TODO: Add checkbox for allowing credit and say may be legally required181 215 // Display the options form. 182 216 summarizes_show_tab_options( $tab ); … … 202 236 $disclose_ai 203 237 ); 238 204 239 if ( summarizes_fs()->can_use_premium_code() ) { 205 240 summarizes_show_pro_settings__premium_only( … … 210 245 $summary_type 211 246 ); 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 213 264 } 214 265 … … 251 302 <ul style="list-style: '✓ ' outside none;"> 252 303 <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> 258 310 </ul> 259 311 <form action="https://checkout.freemius.com/mode/dialog/plugin/12317/plan/20924/"> … … 345 397 </table> 346 398 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> 348 400 349 401 <?php … … 414 466 if ( !function_exists( 'summarizes_show_pro_settings__premium_only' ) ) { 415 467 } 468 if ( !function_exists( 'summarizes_show_pro_pull_quote_settings__premium_only' ) ) { 469 } 470 if ( !function_exists( 'summarizes_show_pro_faq_settings__premium_only' ) ) { 471 } 416 472 417 473 if ( !function_exists( 'summarize_single_post' ) ) { … … 429 485 // Add the new post to the list to summarize 430 486 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 ); 432 488 summarizes_add_summary_to_post_meta( $the_post, $posts_to_summarize ); 433 489 summarizes_log( "resummarize_updated_post post_ID=\"" . $post_ID . "\"", false ); … … 516 572 // Prepares posts for summary, adds license information, 517 573 // and calls the REST interface 518 function summarizes_prepare_arrays_for_summary( array $post_array ) : array574 function summarizes_prepare_arrays_for_summary( array $post_array, array $posts, bool $force ) : array 519 575 { 520 576 $license_array = [ … … 525 581 "summarytype" => summarizes_get_summary_type(), 526 582 ]; 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 527 638 $summary_array = [ 528 639 "posts" => $post_array, … … 541 652 { 542 653 $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"];545 654 // Verify there wasn't an issue finding the post's summary 546 655 547 if ( $post_summary_array == null || $post_method == null) {656 if ( array_key_exists( $permalink, $posts_to_summarize["summarydetails"] ) == false ) { 548 657 // There was an error with finding the page's summary 549 // Log and return550 658 summarizes_log( "summarizes_add_summary_to_post_meta could not find permalink {$permalink} in posts_to_summarize=\"" . summarizes_implode_recursive( $posts_to_summarize ) . "\"", false ); 551 659 } 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 555 690 } 556 691 … … 560 695 if ( !function_exists( 'summarizes_implode_recursive' ) ) { 561 696 // 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 565 706 } 566 707 … … 583 724 584 725 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; 586 733 } else { 587 734 return false; … … 592 739 } 593 740 if ( !function_exists( 'summarizes_check_pro_better_summary_exists__premium_only' ) ) { 741 } 742 if ( !function_exists( 'summarizes_check_faq_and_pull_quote_exist__premium_only' ) ) { 594 743 } 595 744 if ( !function_exists( 'summarizes_call_summarizer' ) ) {
Note: See TracChangeset
for help on using the changeset viewer.