محتويات الموضوع
إخفاء
قد يرغب البعض من اصحاب المواقع والمدونات في ادراج حقوق النشر ولكن منذ بداية التدوين وحتى السنة الحالية ويراه البعض مهم بالنسبة لهم.
الكود الأول
الملفات المطلوب التعديل عليها في القالب الذي تستخدمه
- ملف functions.php
- ملف footer.php
حرر ملف functions.php وضع الكود التالي في نهايته
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
/* Copyright Code ------- */ function ed_comicpress_copyright() { global $wpdb; $copyright_dates = $wpdb->get_results(" SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status = 'publish' "); $output = ''; if($copyright_dates) { $copyright = "© " . $copyright_dates[0]->firstdate; if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) { $copyright .= '-' . $copyright_dates[0]->lastdate; } $output = $copyright; } return $output; } |
واحفظ التعديل
حرر ملف footer.php واضف الكود التالي حيث تريد ان يظهر لك
1 |
<?php echo ed_comicpress_copyright(); ?> |
احفظ التعديلات , وشاهد النتيجة
الكود الثاني
الملفات المطلوب التعديل عليها في القالب الذي تستخدمه
- ملف functions.php
- ملف footer.php
حرر ملف functions.php وضع الكود التالي في نهايته
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
/** * Get footer credits text * * @param array $args * @return string */ function ed_get_footer_credits_text( $args = array() ) { global $wpdb; $defaults = array( 'first_year' => get_transient( 'ed_get_first_year' ), 'current_year' => date( 'Y' ), 'symbol' => '©', 'text' => esc_html__( 'جميع الحقوق محفوظة', 'text-domain' ), 'site_name' => get_bloginfo( 'name' ), 'text_separator' => ' | ', 'years_separator' => '-', ); extract( apply_filters( 'ed_footer_credits_args', wp_parse_args( (array) $args, $defaults ) ) ); if ( false === $first_year ) { $sql = "SELECT YEAR(min(post_date_gmt)) AS first_year FROM $wpdb->posts WHERE post_status = 'publish'"; if ( false === $first_year ) { $post_date_gmt = $wpdb->get_results( $sql ); // WPCS: cache ok. db call ok. unprepared SQL OK. if ( is_array( $post_date_gmt ) ) { set_transient( 'ed_get_first_year', $post_date_gmt[0]->first_year, MONTH_IN_SECONDS ); unset( $post_date_gmt ); } } } $output = $text . $text_separator . $site_name . ' ' . $symbol . ' '; if ( $current_year !== $first_year ) { $years = $first_year . $years_separator . $current_year; $output .= $years; } else { $output .= $current_year; } return apply_filters( 'ed_footer_credits_text', $output ); } |
واحفظ التعديل
حرر ملف footer.php واضف الكود التالي حيث تريد ان يظهر لك
1 |
<?php echo esc_html( ed_get_footer_credits_text() ) ?> |
احفظ التعديلات