Skip to content

Instantly share code, notes, and snippets.

@mwordpress
mwordpress / content-filter.php
Created February 10, 2017 22:35
the codes listed here is part of the following article : https://www.mwordpress.net/how-to-add-adsense-into-post-wordpress/
<?php
$content = apply_filters('the_content', $post->post_content);
$save = explode("</p>", $content);
$tcount = 0;
$adon = 0;
foreach($save as $item) {
echo $item;
echo "</p>";
if(preg_match('/<p> /',$item) == 0 && $tcount >= 1 && $adon == 0) {
$adon=1;
# BEGIN supercache
<IfModule mod_mime.c>
<FilesMatch "\.html\.gz$">
ForceType text/html
FileETag None
</FilesMatch>
AddEncoding gzip .gz
AddType text/html .gz
</IfModule>
<IfModule mod_deflate.c>
function wpse_footer_db_queries(){
echo '<!-- '.get_num_queries().' queries in '.timer_stop(0).' seconds. -->'.PHP_EOL;
}
add_action('wp_footer', 'wpse_footer_db_queries');
@mwordpress
mwordpress / readme.htaccess
Last active February 10, 2017 21:55
the codes listed here is part of the following article : https://www.mwordpress.net/protect-files-and-folders-to-wordpress-blog/
# Protect Readme files
<FilesMatch "readme.html">
order allow,deny
deny from all
satisfy all
</FilesMatch>
<FilesMatch "readme.txt">
order allow,deny
deny from all
/*
تنسيقات الهاك
يحب عليك تعديلها على حسب الشكل الذي تريد عررض المواضيع بها
*/
.custom-related {
margin:0;
padding:2%;
width:96%;
}
.custom-related h2{
/*
* get content and clean
*/
function mwp_post_content($post_id) {
$post = get_post($post_id);
$output = $post->post_content;
$replace = "@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@";
$output = wp_strip_all_tags($output, true);
$output = strip_shortcodes($output);
$output = ltrim($output);
<link rel="image_src" href="رابط الصورة" />
<meta property="og:image" content="رابط الصورة" />
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">