Skip to content

Instantly share code, notes, and snippets.

View andornagy's full-sized avatar

Andor Nagy andornagy

View GitHub Profile
<?php
add_filter('widget_text', 'php_text', 99);
function php_text($text) {
if (strpos($text, '<' . '?') !== false) {
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
<?php
function my_widgets_init() {
//Registering Prymar Widget Area
register_sidebar( array(
// The name of the sidebar
'name' => __( 'Primary Sidebar' ),
// The ID of the sidebar ( used to display it )
'id' => 'primary_header',
// A short description of the sidebar ( visibile only in the admin panel )
'description' => __( 'This is the Primary Sidebar', 'acer' ),
<?php
function is_sidebar_active($index) {
global $wp_registered_sidebars;
$widgetcolums = wp_get_sidebars_widgets();
if ($widgetcolums[$index])
return true;
return false;
}
@andornagy
andornagy / marker.css
Last active December 25, 2015 20:49
Pure CSS Dorpdown Menu
li > a:after { content: ' »'; } /* Change this in order to change the Dropdown symbol */
li > a:only-child:after { content: ''; }
@andornagy
andornagy / non-www
Created May 25, 2013 12:38
Force www and non-www
# Redirect www urls to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?url=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?url=$1
RewriteRule ^(.+)(\s|%20)(.+)$ /$1-$3 [R=301,QSA,L,NE]
@andornagy
andornagy / function.php
Last active December 17, 2015 10:59
function.php
<?php get_category_by_slug( $slug ) ?>
<?
$q = new query();
if ( $result = $q->query( $q->the_query() ) ) {
while ( $row = $q->the_post( $result ) ) { ?>
<h2><?php echo $q->the_title($row) ?></h2>
<?php echo $q->the_content($row) ?>
<?php
$rank = 2; // Admin
?>
<select class="select" name="rank">
<option<?php if ($rank == '1' ) { ?> selected="selected" <?php } ?> value="1">User</option>
<option<?php if ($rank == '2' ) { ?> selected="selected" <?php } ?> value="2">Admin</option>
</select>
#pop {
z-index:999999;
position:fixed relative;
margin:20% auto;
display:none;
width:200px;
height:200px;
border: 1px solid #000;
}