Skip to content

Instantly share code, notes, and snippets.

View serkanalgur's full-sized avatar
🇹🇷
🇦🇿 Selam / Salam / Hi!

Serkan Algur serkanalgur

🇹🇷
🇦🇿 Selam / Salam / Hi!
View GitHub Profile
@serkanalgur
serkanalgur / gist:3783555
Created September 25, 2012 18:23
function for comments shortcode
function phpcode($atts, $content = "") {
return '<pre class="php">'.esc_attr($content).'</pre>';
}
function csscode($atts, $content = "") {
return '<pre class="css">'.$content.'</pre>';
}
function htmlcode($atts, $content = "") {
return '<pre class="html">'.esc_html($content).'</pre>';
}
function init_common_shortcodes() {
// Sorgu
$the_query = new WP_Query( $args );
// Loop Döngüsü
if ( $the_query-&gt;have_posts() ) {
echo '&lt;ul&gt;';
while ( $the_query-&gt;have_posts() ) {
$the_query-&gt;the_post();
echo '&lt;li&gt;' . get_the_title() . '&lt;/li&gt;';
}
$args = array(
//Sayfa ve Yazı parametreleri
'p' =&gt; 1,
'name' =&gt; 'hello-world',
'page_id' =&gt; 1,
'pagename' =&gt; 'sample-page',
'post_parent' =&gt; 1,
'post__in' =&gt; array(1,2,3),
'post__not_in' =&gt; array(1,2,3),
// Get user IP in WordPress
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
@serkanalgur
serkanalgur / search_block_transient.php
Last active April 15, 2025 13:00
Search Block in Transient (30 Sec)
<?php
// Get user IP in WordPress
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
<-- HTML -->
<figure>
<video src="_assets/video/sample.webm" controls autoplay
width="400"
height="300"
id="video-ornek"
data-description="web video örneği">
tarayıcınız video etiketini desteklememekte </video>
<legend></legend>
</figure>
@serkanalgur
serkanalgur / video_ornek.html
Last active October 16, 2017 21:31
Video Etiket Örneği
<-- HTML -->
<figure>
<video src="_assets/video/sample.webm" controls autoplay
width="400"
height="300"
id="video-ornek"
data-description="web video örneği">
tarayıcınız video etiketini desteklememekte </video>
<legend></legend>
</figure>
@media screen and (min-width: 480px) {
body {
background-color: lightgreen;
}
}
<?php
//Aşağıdaki kodlar functions.php içine eklenecek
add_action( 'generate_rewrite_rules', 'ilan_ek_kurallar_temiz' );
function ilan_ek_kurallar_temiz( $wp_rewrite ) {
$new_rules = array(
'products/([^/]+)/?$' => 'index.php?sehir=' . $wp_rewrite->preg_index( 1 ),
'products/([^/]+)/([^/]+)/?$' => 'index.php?post_type=ilan&sehir=' . $wp_rewrite->preg_index( 1 ) . '&ilan=' . $wp_rewrite->preg_index( 2 ),
'products/([^/]+)/([^/]+)/page/(\d{1,})/?$' => 'index.php?post_type=ilan&sehir=' . $wp_rewrite->preg_index( 1 ) . '&paged=' . $wp_rewrite->preg_index( 3 ),
'products/([^/]+)/([^/]+)/([^/]+)/?$' => 'index.php?post_type=ilan&sehir=' . $wp_rewrite->preg_index( 2 ) . '&ilan=' . $wp_rewrite->preg_index( 3 ),
@serkanalgur
serkanalgur / Git push deployment in 7 easy steps.md
Created June 16, 2018 22:07 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook