Changeset 3376504
- Timestamp:
- 10/11/2025 03:40:42 AM (4 months ago)
- Location:
- facilitated-routines/trunk
- Files:
-
- 4 edited
-
facilitated-routines.php (modified) (4 diffs)
-
includes/admin-ui.php (modified) (12 diffs)
-
includes/sitemap.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
facilitated-routines/trunk/facilitated-routines.php
r3376457 r3376504 3 3 * Plugin Name: Facilitated Routines 4 4 * Description: Optimizes images on demand and generates webp files to improve SEO. Security tweaks, media cleanup, and more. 5 * Version: 2.6.3 35 * Version: 2.6.34 6 6 * Author: Lucas Ferraz SEO 7 7 * Author URI: https://lucasferrazseo.com … … 16 16 define( 'FACIRO_MIN_WP', '6.8' ); 17 17 define( 'FACIRO_MIN_PHP', '8.0' ); 18 define( 'FACIRO_VERSION', '2.6.3 3' );18 define( 'FACIRO_VERSION', '2.6.34' ); 19 19 define( 'FACIRO_FILE', __FILE__ ); 20 20 define( 'FACIRO_DIR', plugin_dir_path( __FILE__ ) ); … … 28 28 return true; 29 29 } 30 /** 31 * Copia arquivos de tradução para a pasta wp-content/languages/plugins/ 32 */ 33 function faciro_copy_translation_files() { 34 $source_dir = FACIRO_DIR . 'languages/'; 35 $target_dir = WP_CONTENT_DIR . '/languages/plugins/'; 36 37 // Criar diretório de destino se não existir 38 if ( ! file_exists( $target_dir ) ) { 39 wp_mkdir_p( $target_dir ); 40 } 41 42 // Verificar se o diretório de origem existe 43 if ( ! file_exists( $source_dir ) ) { 44 return false; 45 } 46 47 // Obter lista de arquivos de tradução (.mo e .po) 48 $translation_files = array_merge( 49 glob( $source_dir . '*.mo' ), 50 glob( $source_dir . '*.po' ) 51 ); 52 53 $copied_count = 0; 54 55 foreach ( $translation_files as $file ) { 56 $filename = basename( $file ); 57 $target_file = $target_dir . $filename; 58 59 // Copiar arquivo se o arquivo de destino não existir ou for mais antigo 60 if ( ! file_exists( $target_file ) || filemtime( $file ) > filemtime( $target_file ) ) { 61 if ( copy( $file, $target_file ) ) { 62 $copied_count++; 63 } 64 } 65 } 66 67 return $copied_count; 68 } 69 70 /** 71 * Lê o conteúdo atual do arquivo robots.txt diretamente do servidor 72 */ 73 function faciro_get_robots_content() { 74 $robots_file = ABSPATH . 'robots.txt'; 75 76 if ( file_exists( $robots_file ) && is_readable( $robots_file ) ) { 77 $content = file_get_contents( $robots_file ); 78 // Garantir que retorna string mesmo se file_get_contents falhar 79 return $content !== false ? $content : ''; 80 } 81 82 return ''; 83 } 84 85 /** 86 * Cria ou atualiza o arquivo robots.txt na raiz do WordPress 87 */ 88 function faciro_create_robots_txt( $content ) { 89 $robots_file = ABSPATH . 'robots.txt'; 90 91 // Criar arquivo robots.txt 92 $result = file_put_contents( $robots_file, $content, LOCK_EX ); 93 94 if ( $result !== false ) { 95 // Verificar se o arquivo foi criado corretamente 96 if ( file_exists( $robots_file ) && filesize( $robots_file ) > 0 ) { 97 return true; 98 } 99 } 100 101 return false; 102 } 103 104 /** 105 * Lê o conteúdo atual do arquivo llms.txt diretamente do servidor 106 */ 107 function faciro_get_llms_content() { 108 $llms_file = ABSPATH . 'llms.txt'; 109 110 if ( file_exists( $llms_file ) && is_readable( $llms_file ) ) { 111 $content = file_get_contents( $llms_file ); 112 113 if ( $content !== false ) { 114 // Remover BOM UTF-8 se presente 115 if ( substr( $content, 0, 3 ) === "\xEF\xBB\xBF" ) { 116 $content = substr( $content, 3 ); 117 } 118 119 // Garantir codificação UTF-8 120 $content = mb_convert_encoding( $content, 'UTF-8', 'auto' ); 121 122 return $content; 123 } 124 } 125 126 return ''; 127 } 128 129 /** 130 * Cria ou atualiza o arquivo llms.txt na raiz do WordPress 131 */ 132 function faciro_create_llms_txt( $content ) { 133 $llms_file = ABSPATH . 'llms.txt'; 134 135 // Garantir que o conteúdo está em UTF-8 136 $content = mb_convert_encoding( $content, 'UTF-8', 'auto' ); 137 138 // Adicionar BOM UTF-8 para garantir codificação correta 139 $utf8_content = "\xEF\xBB\xBF" . $content; 140 141 // Criar arquivo llms.txt com codificação UTF-8 142 $result = file_put_contents( $llms_file, $utf8_content, LOCK_EX ); 143 144 if ( $result !== false ) { 145 // Verificar se o arquivo foi criado corretamente 146 if ( file_exists( $llms_file ) && filesize( $llms_file ) > 0 ) { 147 return true; 148 } 149 } 150 151 return false; 152 } 153 30 154 function faciro_activation_check() { 31 155 if ( ! faciro_requirements_met() ) { … … 71 195 } 72 196 197 // Copiar arquivos de tradução 198 faciro_copy_translation_files(); 199 73 200 // Flush rewrite rules na ativação do plugin 74 201 flush_rewrite_rules(); 75 202 } 76 203 register_activation_hook( __FILE__, 'faciro_activation_check' ); 204 205 // Hook para atualização do plugin 206 add_action( 'upgrader_process_complete', function( $upgrader_object, $options ) { 207 // Verificar se é uma atualização de plugin 208 if ( $options['action'] === 'update' && $options['type'] === 'plugin' ) { 209 if ( isset( $options['plugins'] ) && is_array( $options['plugins'] ) ) { 210 foreach ( $options['plugins'] as $plugin ) { 211 if ( strpos( $plugin, 'facilitated-routines' ) !== false ) { 212 // Copiar arquivos de tradução na atualização 213 faciro_copy_translation_files(); 214 break; 215 } 216 } 217 } 218 } 219 }, 10, 2 ); 220 77 221 78 222 if ( ! faciro_requirements_met() ) { return; } -
facilitated-routines/trunk/includes/admin-ui.php
r3376455 r3376504 12 12 register_setting( 'faciro_settings', 'faciro_enable_optimize', array( 'type'=>'boolean','default'=>1,'sanitize_callback'=>$sanitize ) ); 13 13 register_setting( 'faciro_settings', 'faciro_enable_webp', array( 'type'=>'boolean','default'=>1,'sanitize_callback'=>$sanitize ) ); 14 register_setting( 'faciro_settings', 'faciro_fill_image_title', array( 'type'=>'boolean','default'=>1,'sanitize_callback'=>$sanitize ) );15 register_setting( 'faciro_settings', 'faciro_fill_image_description', array( 'type'=>'boolean','default'=>1,'sanitize_callback'=>$sanitize ) );16 register_setting( 'faciro_settings', 'faciro_fill_image_caption', array( 'type'=>'boolean','default'=>1,'sanitize_callback'=>$sanitize ) );17 14 18 15 register_setting( 'faciro_settings_wp', 'faciro_hide_wp_version', array( 'type'=>'boolean','default'=>1,'sanitize_callback'=>$sanitize ) ); … … 549 546 } 550 547 551 /* Sitemap Dependent Options */552 .fr-sitemap-dependent {553 transition: all 0.3s ease;554 opacity: 0.7;555 }556 557 .fr-sitemap-dependent:not([style*="display: none"]) {558 opacity: 1;559 }560 561 548 /* Improved Grid Layout */ 562 549 .fr-grid label { … … 629 616 <div class="wrap"> 630 617 <h1> 631 <span style="display: inline-block; margin-right: 12px;">🚀</span>632 618 <?php echo esc_html__( 'Facilitated Routines', 'facilitated-routines' ); ?> 633 619 <span style="display: block; font-size: 16px; font-weight: 400; margin-top: 8px; opacity: 0.9;"> … … 706 692 <label> 707 693 <input type="hidden" name="faciro_sitemap_enabled" value="0"> 708 <input type="checkbox" name="faciro_sitemap_enabled" id="faciro_sitemap_enabled"value="1" <?php checked(1,(int)get_option('faciro_sitemap_enabled',0)); ?> />694 <input type="checkbox" name="faciro_sitemap_enabled" value="1" <?php checked(1,(int)get_option('faciro_sitemap_enabled',0)); ?> /> 709 695 <div> 710 696 <strong><?php esc_html_e('Enable sitemaps','facilitated-routines'); ?></strong> … … 713 699 </label> 714 700 <label> 715 <input type="hidden" name="faciro_robots_txt_enabled" value="0">716 <input type="checkbox" name="faciro_robots_txt_enabled" value="1" <?php checked(1,(int)get_option('faciro_robots_txt_enabled',0)); ?> />717 <div>718 <strong><?php esc_html_e('Enable robots.txt','facilitated-routines'); ?></strong>719 <br><small><?php esc_html_e('Automatically generates a robots.txt file with SEO settings.','facilitated-routines'); ?></small>720 </div>721 </label>722 <label class="fr-sitemap-dependent" style="display: none;">723 701 <input type="hidden" name="faciro_sitemap_posts" value="0"> 724 702 <input type="checkbox" name="faciro_sitemap_posts" value="1" <?php checked(1,(int)get_option('faciro_sitemap_posts',1)); ?> /> … … 728 706 </div> 729 707 </label> 730 <label class="fr-sitemap-dependent" style="display: none;">708 <label> 731 709 <input type="hidden" name="faciro_sitemap_pages" value="0"> 732 710 <input type="checkbox" name="faciro_sitemap_pages" value="1" <?php checked(1,(int)get_option('faciro_sitemap_pages',1)); ?> /> … … 736 714 </div> 737 715 </label> 738 <label class="fr-sitemap-dependent" style="display: none;">716 <label> 739 717 <input type="hidden" name="faciro_sitemap_authors" value="0"> 740 718 <input type="checkbox" name="faciro_sitemap_authors" value="1" <?php checked(1,(int)get_option('faciro_sitemap_authors',1)); ?> /> … … 744 722 </div> 745 723 </label> 746 <label class="fr-sitemap-dependent" style="display: none;">724 <label> 747 725 <input type="hidden" name="faciro_sitemap_news" value="0"> 748 726 <input type="checkbox" name="faciro_sitemap_news" value="1" <?php checked(1,(int)get_option('faciro_sitemap_news',1)); ?> /> … … 752 730 </div> 753 731 </label> 754 <label class="fr-sitemap-dependent" style="display: none;"> 755 <input type="hidden" name="faciro_sitemap_custom_posts" value="0"> 756 <input type="checkbox" name="faciro_sitemap_custom_posts" value="1" <?php checked(1,(int)get_option('faciro_sitemap_custom_posts',1)); ?> /> 757 <div> 758 <strong><?php esc_html_e('Include custom post types','facilitated-routines'); ?></strong> 759 <br><small><?php esc_html_e('Generate sitemaps for custom post types.','facilitated-routines'); ?></small> 760 </div> 761 </label> 732 <?php 733 // Obter todos os custom post types ativos 734 $custom_post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'objects' ); 735 foreach ( $custom_post_types as $post_type ) { 736 $option_name = 'faciro_sitemap_' . $post_type->name; 737 $label = $post_type->labels->name; 738 /* translators: %s: Custom post type name */ 739 $description = sprintf( __( 'Generate sitemap for %s.', 'facilitated-routines' ), strtolower( $label ) ); 740 ?> 741 <label> 742 <input type="hidden" name="<?php echo esc_attr( $option_name ); ?>" value="0"> 743 <input type="checkbox" name="<?php echo esc_attr( $option_name ); ?>" value="1" <?php checked(1,(int)get_option($option_name,1)); ?> /> 744 <div> 745 <?php /* translators: %s: Custom post type name */ ?> 746 <strong><?php echo esc_html( sprintf( __( 'Include %s', 'facilitated-routines' ), strtolower( $label ) ) ); ?></strong> 747 <br><small><?php echo esc_html( $description ); ?></small> 748 </div> 749 </label> 750 <?php 751 } 752 753 // Obter todas as taxonomias ativas 754 $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); 755 foreach ( $taxonomies as $taxonomy ) { 756 $option_name = 'faciro_sitemap_' . $taxonomy->name; 757 $label = $taxonomy->labels->name; 758 /* translators: %s: Taxonomy name */ 759 $description = sprintf( __( 'Generate sitemap for %s.', 'facilitated-routines' ), strtolower( $label ) ); 760 ?> 761 <label> 762 <input type="hidden" name="<?php echo esc_attr( $option_name ); ?>" value="0"> 763 <input type="checkbox" name="<?php echo esc_attr( $option_name ); ?>" value="1" <?php checked(1,(int)get_option($option_name,1)); ?> /> 764 <div> 765 <?php /* translators: %s: Taxonomy name */ ?> 766 <strong><?php echo esc_html( sprintf( __( 'Include %s', 'facilitated-routines' ), strtolower( $label ) ) ); ?></strong> 767 <br><small><?php echo esc_html( $description ); ?></small> 768 </div> 769 </label> 770 <?php 771 } 772 ?> 762 773 </div> 763 774 <?php submit_button( esc_html__( 'Save sitemap settings', 'facilitated-routines' ) ); ?> 764 775 </form> 765 776 777 </div> 778 779 <div class="fr-card"> 780 <h2><?php echo esc_html__( 'robots.txt', 'facilitated-routines' ); ?></h2> 781 <p><?php echo esc_html__( 'Create or edit the robots.txt file for your website. This file tells search engines how to crawl your site.', 'facilitated-routines' ); ?></p> 782 <form id="robots-form" method="post" action=""> 783 <?php wp_nonce_field( 'faciro_robots_save', 'faciro_robots_nonce' ); ?> 784 <div style="margin-bottom: 20px;"> 785 <textarea 786 id="robots-content" 787 name="robots_content" 788 rows="10" 789 style="width: 100%; font-family: monospace; font-size: 14px; padding: 15px; border: 1px solid #ddd; border-radius: 8px; resize: vertical;" 790 placeholder="<?php esc_attr_e( 'Enter robots.txt content here...', 'facilitated-routines' ); ?>" 791 ><?php echo esc_textarea( faciro_get_robots_content() ); ?></textarea> 792 </div> 793 <div style="display: flex; gap: 12px; flex-wrap: wrap;"> 794 <button type="submit" name="save_robots" class="button button-primary"> 795 <?php echo esc_html__( 'Save', 'facilitated-routines' ); ?> 796 </button> 797 <button type="submit" name="default_robots" class="button button-secondary"> 798 <?php echo esc_html__( 'Default', 'facilitated-routines' ); ?> 799 </button> 800 </div> 801 </form> 802 803 <?php 804 // Processar formulário 805 if ( isset( $_POST['save_robots'] ) || isset( $_POST['default_robots'] ) ) { 806 if ( isset( $_POST['faciro_robots_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['faciro_robots_nonce'] ) ), 'faciro_robots_save' ) ) { 807 if ( current_user_can( 'manage_options' ) ) { 808 if ( isset( $_POST['default_robots'] ) ) { 809 // Conteúdo padrão 810 $default_content = "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n\nSitemap: " . home_url( '/sitemap-index.xml' ); 811 812 // Criar/atualizar arquivo robots.txt na raiz 813 if ( faciro_create_robots_txt( $default_content ) ) { 814 echo '<div class="notice notice-success"><p>' . esc_html__( 'robots.txt created with default content.', 'facilitated-routines' ) . '</p></div>'; 815 // Atualizar textarea sem reload 816 echo '<script>document.getElementById("robots-content").value = ' . json_encode( $default_content ) . ';</script>'; 817 } else { 818 echo '<div class="notice notice-error"><p>' . esc_html__( 'Error creating robots.txt file.', 'facilitated-routines' ) . '</p></div>'; 819 } 820 } else { 821 // Salvar conteúdo personalizado 822 $content = isset( $_POST['robots_content'] ) ? sanitize_textarea_field( wp_unslash( $_POST['robots_content'] ) ) : ''; 823 824 // Criar/atualizar arquivo robots.txt na raiz 825 if ( faciro_create_robots_txt( $content ) ) { 826 echo '<div class="notice notice-success"><p>' . esc_html__( 'robots.txt saved successfully.', 'facilitated-routines' ) . '</p></div>'; 827 // Atualizar textarea sem reload 828 echo '<script>document.getElementById("robots-content").value = ' . json_encode( $content ) . ';</script>'; 829 } else { 830 echo '<div class="notice notice-error"><p>' . esc_html__( 'Error saving robots.txt file.', 'facilitated-routines' ) . '</p></div>'; 831 } 832 } 833 } 834 } 835 } 836 ?> 837 </div> 838 839 <div class="fr-card"> 840 <h2><?php echo esc_html__( 'llms.txt', 'facilitated-routines' ); ?></h2> 841 <p><?php echo esc_html__( 'Create or edit the llms.txt file for your website. This file provides information about your site for AI models and language learning systems.', 'facilitated-routines' ); ?></p> 842 <form id="llms-form" method="post" action=""> 843 <?php wp_nonce_field( 'faciro_llms_save', 'faciro_llms_nonce' ); ?> 844 <div style="margin-bottom: 20px;"> 845 <textarea 846 id="llms-content" 847 name="llms_content" 848 rows="15" 849 style="width: 100%; font-family: monospace; font-size: 14px; padding: 15px; border: 1px solid #ddd; border-radius: 8px; resize: vertical;" 850 placeholder="<?php esc_attr_e( 'Enter llms.txt content here...', 'facilitated-routines' ); ?>" 851 ><?php echo esc_textarea( faciro_get_llms_content() ); ?></textarea> 852 </div> 853 <div style="display: flex; gap: 12px; flex-wrap: wrap;"> 854 <button type="submit" name="save_llms" class="button button-primary"> 855 <?php echo esc_html__( 'Save', 'facilitated-routines' ); ?> 856 </button> 857 <button type="submit" name="default_llms" class="button button-secondary"> 858 <?php echo esc_html__( 'Default', 'facilitated-routines' ); ?> 859 </button> 860 </div> 861 </form> 862 863 <?php 864 // Processar formulário llms.txt 865 if ( isset( $_POST['save_llms'] ) || isset( $_POST['default_llms'] ) ) { 866 if ( isset( $_POST['faciro_llms_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['faciro_llms_nonce'] ) ), 'faciro_llms_save' ) ) { 867 if ( current_user_can( 'manage_options' ) ) { 868 if ( isset( $_POST['default_llms'] ) ) { 869 // Conteúdo padrão do llms.txt 870 $site_name = get_bloginfo( 'name' ); 871 $site_description = get_bloginfo( 'description' ); 872 873 // Normalizar codificação UTF-8 874 $site_name = mb_convert_encoding( $site_name, 'UTF-8', 'auto' ); 875 $site_description = mb_convert_encoding( $site_description, 'UTF-8', 'auto' ); 876 877 // Se não houver descrição, usar uma padrão 878 if ( empty( $site_description ) ) { 879 $site_description = 'Portal de informações úteis para o dia a dia das pessoas'; 880 } 881 882 $default_content = "# {$site_name}: {$site_description}\n\n"; 883 884 // Adicionar posts recentes 885 $recent_posts = get_posts( array( 886 'numberposts' => 50, 887 'post_status' => 'publish', 888 'orderby' => 'date', 889 'order' => 'DESC' 890 ) ); 891 892 if ( ! empty( $recent_posts ) ) { 893 $default_content .= "## Posts\n"; 894 foreach ( $recent_posts as $post ) { 895 $excerpt = $post->post_excerpt ?: wp_trim_words( wp_strip_all_tags( $post->post_content ), 20 ); 896 $excerpt = html_entity_decode( $excerpt, ENT_QUOTES, 'UTF-8' ); 897 $excerpt = mb_convert_encoding( $excerpt, 'UTF-8', 'auto' ); 898 $post_url = get_permalink( $post->ID ); 899 $post_title = html_entity_decode( $post->post_title, ENT_QUOTES, 'UTF-8' ); 900 $post_title = mb_convert_encoding( $post_title, 'UTF-8', 'auto' ); 901 $default_content .= "- [{$post_title}]({$post_url}): {$excerpt}\n"; 902 } 903 $default_content .= "\n"; 904 } 905 906 // Adicionar páginas 907 $pages = get_posts( array( 908 'post_type' => 'page', 909 'numberposts' => -1, 910 'post_status' => 'publish', 911 'orderby' => 'title', 912 'order' => 'ASC' 913 ) ); 914 915 if ( ! empty( $pages ) ) { 916 $default_content .= "## Páginas\n"; 917 foreach ( $pages as $page ) { 918 $excerpt = $page->post_excerpt ?: wp_trim_words( wp_strip_all_tags( $page->post_content ), 15 ); 919 $excerpt = html_entity_decode( $excerpt, ENT_QUOTES, 'UTF-8' ); 920 $excerpt = mb_convert_encoding( $excerpt, 'UTF-8', 'auto' ); 921 $page_url = get_permalink( $page->ID ); 922 $page_title = html_entity_decode( $page->post_title, ENT_QUOTES, 'UTF-8' ); 923 $page_title = mb_convert_encoding( $page_title, 'UTF-8', 'auto' ); 924 if ( $excerpt ) { 925 $default_content .= "- [{$page_title}]({$page_url}): {$excerpt}\n"; 926 } else { 927 $default_content .= "- [{$page_title}]({$page_url})\n"; 928 } 929 } 930 } 931 932 // Criar/atualizar arquivo llms.txt na raiz 933 if ( faciro_create_llms_txt( $default_content ) ) { 934 echo '<div class="notice notice-success"><p>' . esc_html__( 'llms.txt created with default content.', 'facilitated-routines' ) . '</p></div>'; 935 // Atualizar textarea sem reload 936 echo '<script>document.getElementById("llms-content").value = ' . json_encode( $default_content ) . ';</script>'; 937 } else { 938 echo '<div class="notice notice-error"><p>' . esc_html__( 'Error creating llms.txt file.', 'facilitated-routines' ) . '</p></div>'; 939 } 940 } else { 941 // Salvar conteúdo personalizado 942 $content = isset( $_POST['llms_content'] ) ? sanitize_textarea_field( wp_unslash( $_POST['llms_content'] ) ) : ''; 943 944 // Criar/atualizar arquivo llms.txt na raiz 945 if ( faciro_create_llms_txt( $content ) ) { 946 echo '<div class="notice notice-success"><p>' . esc_html__( 'llms.txt saved successfully.', 'facilitated-routines' ) . '</p></div>'; 947 // Atualizar textarea sem reload 948 echo '<script>document.getElementById("llms-content").value = ' . json_encode( $content ) . ';</script>'; 949 } else { 950 echo '<div class="notice notice-error"><p>' . esc_html__( 'Error saving llms.txt file.', 'facilitated-routines' ) . '</p></div>'; 951 } 952 } 953 } 954 } 955 } 956 ?> 766 957 </div> 767 958 … … 824 1015 <div> 825 1016 <strong><?php esc_html_e('Fill image title','facilitated-routines'); ?></strong> 826 <br><small><?php esc_html_e('Automatically fills the image title fieldwith the post title when renaming images.','facilitated-routines'); ?></small>1017 <br><small><?php esc_html_e('Automatically fills the image title with the post title when renaming images.','facilitated-routines'); ?></small> 827 1018 </div> 828 1019 </label> … … 832 1023 <div> 833 1024 <strong><?php esc_html_e('Fill image description','facilitated-routines'); ?></strong> 834 <br><small><?php esc_html_e('Automatically fills the image description field with the post excerpt or content.','facilitated-routines'); ?></small> 835 </div> 836 </label> 837 <label> 838 <input type="hidden" name="faciro_fill_image_caption" value="0"> 839 <input type="checkbox" name="faciro_fill_image_caption" value="1" <?php checked(1,(int)get_option('faciro_fill_image_caption',1)); ?> /> 840 <div> 841 <strong><?php esc_html_e('Fill image caption','facilitated-routines'); ?></strong> 842 <br><small><?php esc_html_e('Automatically fills the image caption field with the post excerpt.','facilitated-routines'); ?></small> 1025 <br><small><?php esc_html_e('Automatically fills the image description with the post title when renaming images.','facilitated-routines'); ?></small> 843 1026 </div> 844 1027 </label> … … 856 1039 <?php 857 1040 $opts = array( 858 'faciro_hide_wp_version' => array( __( 'Hide WordPress version', 'facilitated-routines' ), __( 'Hides the WordPress version from the source code', 'facilitated-routines' )),859 'faciro_disable_heartbeat' => array( __( 'Disable Heartbeat', 'facilitated-routines' ), __( 'Disables Heartbeat to reduce AJAX requests', 'facilitated-routines' )),860 'faciro_disable_dashicons_front' => array( __( 'Disable Dashicons on the front end', 'facilitated-routines' ), __( 'Removes Dashicons from frontend for better performance', 'facilitated-routines' )),861 'faciro_remove_shortlink' => array( __( 'Remove Shortlink', 'facilitated-routines' ), __( 'Removes WordPress shortlink functionality', 'facilitated-routines' )),862 'faciro_disable_embed' => array( __( 'Disable Embed', 'facilitated-routines' ), __( 'Disables WordPress embed functionality', 'facilitated-routines' )),863 'faciro_disable_xmlrpc' => array( __( 'Disable XML-RPC', 'facilitated-routines' ), __( 'Disables XML-RPC for enhanced security', 'facilitated-routines' )),864 'faciro_remove_rsd' => array( __( 'Remove RSD links', 'facilitated-routines' ), __( 'Removes RSD (Really Simple Discovery) links', 'facilitated-routines' )),865 'faciro_remove_fse_global_styles' => array( __( 'Remove FSE Global Styles', 'facilitated-routines' ), __( 'Removes Full Site Editing global styles', 'facilitated-routines' )),866 'faciro_remove_emojis' => array( __( 'Remove emoticon scripts', 'facilitated-routines' ), __( 'Removes WordPress emoji scripts', 'facilitated-routines' )),867 'faciro_remove_header_info' => array( __( 'Header cleanup', 'facilitated-routines' ), __( 'Cleans unnecessary header information', 'facilitated-routines' )),868 'faciro_strip_version_assets' => array( __( 'Strip version from assets', 'facilitated-routines' ), __( 'Removes version from CSS and JS files', 'facilitated-routines' )),869 'faciro_hide_login_errors' => array( __( 'Hide login errors', 'facilitated-routines' ), __( 'Hides login errors for enhanced security', 'facilitated-routines' )),870 'faciro_disable_feeds' => array( __( 'Disable all RSS and Atom feeds', 'facilitated-routines' ), __( 'Disables all RSS and Atom feeds', 'facilitated-routines' )),871 'faciro_hide_admin_bar' => array( __( 'Hide admin bar on the front end', 'facilitated-routines' ), __( 'Hides admin bar on the frontend', 'facilitated-routines' )),872 'faciro_prevent_multisite_signup' => array( __( 'Prevent multisite signup page', 'facilitated-routines' ), __( 'Prevents multisite signup page', 'facilitated-routines' )),873 'faciro_remove_x_pingback' => array( __( 'Remove X-Pingback header', 'facilitated-routines' ), __( 'Removes X-Pingback header', 'facilitated-routines' )),874 'faciro_disable_rankmath_sitemap_cache' => array( __( 'Disable Rank Math sitemap cache', 'facilitated-routines' ), __( 'Disables Rank Math sitemap cache', 'facilitated-routines' )),1041 'faciro_hide_wp_version' => array( 'Hide WordPress version', 'Hides the WordPress version from the source code' ), 1042 'faciro_disable_heartbeat' => array( 'Disable Heartbeat', 'Disables Heartbeat to reduce AJAX requests' ), 1043 'faciro_disable_dashicons_front' => array( 'Disable Dashicons on the front end', 'Removes Dashicons from frontend for better performance' ), 1044 'faciro_remove_shortlink' => array( 'Remove Shortlink', 'Removes WordPress shortlink functionality' ), 1045 'faciro_disable_embed' => array( 'Disable Embed', 'Disables WordPress embed functionality' ), 1046 'faciro_disable_xmlrpc' => array( 'Disable XML-RPC', 'Disables XML-RPC for enhanced security' ), 1047 'faciro_remove_rsd' => array( 'Remove RSD links', 'Removes RSD (Really Simple Discovery) links' ), 1048 'faciro_remove_fse_global_styles' => array( 'Remove FSE Global Styles', 'Removes Full Site Editing global styles' ), 1049 'faciro_remove_emojis' => array( 'Remove emoticon scripts', 'Removes WordPress emoji scripts' ), 1050 'faciro_remove_header_info' => array( 'Header cleanup', 'Cleans unnecessary header information' ), 1051 'faciro_strip_version_assets' => array( 'Strip version from assets', 'Removes version from CSS and JS files' ), 1052 'faciro_hide_login_errors' => array( 'Hide login errors', 'Hides login errors for enhanced security' ), 1053 'faciro_disable_feeds' => array( 'Disable all RSS and Atom feeds', 'Disables all RSS and Atom feeds' ), 1054 'faciro_hide_admin_bar' => array( 'Hide admin bar on the front end', 'Hides admin bar on the frontend' ), 1055 'faciro_prevent_multisite_signup' => array( 'Prevent multisite signup page', 'Prevents multisite signup page' ), 1056 'faciro_remove_x_pingback' => array( 'Remove X-Pingback header', 'Removes X-Pingback header' ), 1057 'faciro_disable_rankmath_sitemap_cache' => array( 'Disable Rank Math sitemap cache', 'Disables Rank Math sitemap cache' ), 875 1058 ); 876 1059 foreach ( $opts as $k => $data ) { -
facilitated-routines/trunk/includes/sitemap.php
r3376455 r3376504 39 39 foreach ( $custom_post_types as $post_type ) { 40 40 register_setting( 'faciro_settings_sitemap', 'faciro_sitemap_' . $post_type->name, array( 41 'type' => 'boolean', 42 'default' => 1, 43 'sanitize_callback' => $sanitize 44 ) ); 45 } 46 47 // Registrar opções para taxonomias dinamicamente 48 $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); 49 foreach ( $taxonomies as $taxonomy ) { 50 register_setting( 'faciro_settings_sitemap', 'faciro_sitemap_' . $taxonomy->name, array( 41 51 'type' => 'boolean', 42 52 'default' => 1, … … 284 294 } 285 295 286 // --- Categories --- 287 $type = 'category'; 288 // CORREÇÃO: Usando count( get_terms() ) para evitar o aviso de deprecação do wp_count_terms. 289 $category_count = count( get_terms( array( 290 'taxonomy' => $type, 291 'hide_empty' => false, 292 'cache_domain' => 'not-cached', 293 'fields' => 'ids' // Otimização para contagem 294 ) ) ); 295 296 if ( $category_count > 0 ) { 297 $pages = ceil( $category_count / $per_page ); 298 299 if ( $pages == 1 ) { 300 $sitemaps[] = array( 301 'loc' => home_url( '/sitemap-' . $type . '.xml' ), 302 'lastmod' => faciro_get_last_modified( 'post' ) 303 ); 304 } else { 305 for ( $i = 1; $i <= $pages; $i++ ) { 306 $sitemaps[] = array( 307 'loc' => home_url( '/sitemap-' . $type . $i . '.xml' ), 308 'lastmod' => faciro_get_last_modified( 'post' ) 309 ); 310 } 311 } 312 } 313 314 // --- Tags --- 315 $type = 'post_tag'; 316 // CORREÇÃO: Usando count( get_terms() ) para evitar o aviso de deprecação do wp_count_terms. 317 $tag_count = count( get_terms( array( 318 'taxonomy' => $type, 319 'hide_empty' => false, 320 'cache_domain' => 'not-cached', 321 'fields' => 'ids' // Otimização para contagem 322 ) ) ); 323 324 if ( $tag_count > 0 ) { 325 $pages = ceil( $tag_count / $per_page ); 326 327 if ( $pages == 1 ) { 328 $sitemaps[] = array( 329 'loc' => home_url( '/sitemap-' . $type . '.xml' ), 330 'lastmod' => faciro_get_last_modified( 'post' ) 331 ); 332 } else { 333 for ( $i = 1; $i <= $pages; $i++ ) { 334 $sitemaps[] = array( 335 'loc' => home_url( '/sitemap-' . $type . $i . '.xml' ), 336 'lastmod' => faciro_get_last_modified( 'post' ) 337 ); 296 // --- Taxonomias --- 297 $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' ); 298 foreach ( $taxonomies as $taxonomy ) { 299 $type = $taxonomy->name; 300 $option_name = 'faciro_sitemap_' . $type; 301 if ( get_option( $option_name, 1 ) ) { 302 $term_count = count( get_terms( array( 303 'taxonomy' => $type, 304 'hide_empty' => false, 305 'cache_domain' => 'not-cached', 306 'fields' => 'ids' // Otimização para contagem 307 ) ) ); 308 309 if ( $term_count > 0 ) { 310 $pages = ceil( $term_count / $per_page ); 311 312 if ( $pages == 1 ) { 313 $sitemaps[] = array( 314 'loc' => home_url( '/sitemap-' . $type . '.xml' ), 315 'lastmod' => faciro_get_last_modified( 'post' ) 316 ); 317 } else { 318 for ( $i = 1; $i <= $pages; $i++ ) { 319 $sitemaps[] = array( 320 'loc' => home_url( '/sitemap-' . $type . $i . '.xml' ), 321 'lastmod' => faciro_get_last_modified( 'post' ) 322 ); 323 } 324 } 338 325 } 339 326 } … … 406 393 $urls = faciro_get_news_urls( $page ); 407 394 break; 408 case 'category':409 $urls = faciro_get_taxonomy_urls( 'category', $page );410 break;411 case 'post_tag':412 $urls = faciro_get_taxonomy_urls( 'post_tag', $page );413 break;414 395 default: 415 if ( post_type_exists( $type ) ) { 396 // Verificar se é uma taxonomia 397 if ( taxonomy_exists( $type ) ) { 398 $option_name = 'faciro_sitemap_' . $type; 399 if ( ! get_option( $option_name, 1 ) ) return '<?xml version="1.0" encoding="UTF-8"?><error>Sitemap not found</error>'; 400 $urls = faciro_get_taxonomy_urls( $type, $page ); 401 } 402 // Verificar se é um custom post type 403 elseif ( post_type_exists( $type ) ) { 416 404 $option_name = 'faciro_sitemap_' . $type; 417 405 if ( ! get_option( $option_name, 1 ) ) return '<?xml version="1.0" encoding="UTF-8"?><error>Sitemap not found</error>'; -
facilitated-routines/trunk/readme.txt
r3376457 r3376504 4 4 Tags: images, media, webp, cleanup, security 5 5 Requires at least: 6.8 6 Stable tag: 2.6.3 36 Stable tag: 2.6.34 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.