Skip to content

Instantly share code, notes, and snippets.

@ABooooo
ABooooo / new_gist_file.js
Created December 2, 2015 19:30
change width and height attribut
$("img").attr({
"width": "100%",
"height": "auto"
});
@ABooooo
ABooooo / new_gist_file.php
Created December 4, 2015 09:37
remove FTP at plugin upload or update
/* insert this in wp-config.php */
define('FS_METHOD','direct');
@ABooooo
ABooooo / new_gist_file_0
Last active November 1, 2018 08:11
get image from post
Put this in your functions.php
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
@ABooooo
ABooooo / new_gist_file.js
Created June 30, 2016 09:38
reset css animation (loop)
<script>
setInterval(function(){
var container = document.getElementById('anim');
var tmp = container.innerHTML;
container.innerHTML= tmp;
}, 9000 // length of the whole show in milliseconds
);
</script>
@ABooooo
ABooooo / new_gist_file.js
Created June 30, 2016 09:40
check if contain text
if($.trim($(".secMenu").text()) == "") {
$(".secMenu").remove();
}
@ABooooo
ABooooo / new_gist_file.js
Created June 30, 2016 09:41
check if contain image with timeout
setTimeout(function(){
if ($(".contentHeader").find("img").length > 0) {
$(".content").css("padding","15px 0");
} else {
$(".contentHeader").css("padding","0");
}
},100);
@ABooooo
ABooooo / new_gist_file.js
Created September 1, 2016 06:27
jQuery find text and replace with custom text
(function($){
$(document).ready(function(){
$("div").each(function () {
// var this is the current element's DOM object
if (this.innerHTML.indexOf("CōV") != -1) {
//$(this).addClass('cov');
$(this).html(
$(this).html().replace(/(\")?(CōV)(?!\")/gi, function ($0, $1) {
return $1 ? $0 : '<span class="cov">CōV</span>';
})
@ABooooo
ABooooo / new_gist_file.sass
Created April 5, 2017 07:55
Bullet points
.mainContent .left ul, .mainContent .right ul.bulletPointsList {
display: table;
margin: 0px;
padding: 0px;
}
.mainContent .left ul > li, .mainContent .right ul.bulletPointsList > li {
display: table-row;
margin: 0px;
padding-left: 0px;
@ABooooo
ABooooo / new_gist_file.js
Created July 6, 2017 09:58
Change CSS on scroll
var scroll_pos = 0;
$(document).scroll(function() {
scroll_pos = $(this).scrollTop();
if(scroll_pos > 210) {
$(".navbar-default").css({"background-color": "black" , "padding-top" : 0});
} else {
$(".navbar-default").css({"background-color" : "transparent" , "padding-top" : "30px"});
}
});
@ABooooo
ABooooo / new_gist_file.php
Created September 7, 2017 00:38
show post or page with ID
$post_id = 23;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
echo '<p class="jumboTitle">';
echo $title;
echo '</p>';
echo $queried_post->post_content;
//https://www.tipsandtricks-hq.com/query-or-show-a-specific-post-in-wordpress-php-code-example-44