• НАЧАЛО
  • Услуги

AIT WEB DESIGN - изработка на сайт и СЕО оптимизация

  • НАЧАЛО
  • Услуги
  • No products in cart.
  • Начало
  • Articles posted by afilipov
  • Page 4
15.04.2026

Author: afilipov

Как да направим дизайн на WordPress Login screen

  • 0
afilipov
петък, 24 юни 2016 / Published in Wordpress

Влезте в папката на Вашата тема и отворете с редактор файла functions.php
Поставете следният код, който ще добави специфичният CSS код в login хедъра:

<?
/**
 * @desc attach custom admin login CSS file
 */
function custom_login_css() { 

  echo '<link rel="stylesheet"  href="'.get_bloginfo('template_directory').'/inc/login.css" />';

}
add_action('login_head', 'custom_login_css');

?>

Сега вече може да предефинирате всички стилове, които искате. За примера аз ще използвам моят login screen:

.locale-bg-bg {
    background-color: #f7f7f7 !important;
    background-image: none !important;
    background-image: url('bg-5.jpg')  !important;
    background-repeat: no-repeat !important;
    background-position: 50% 0 !important;
    background-attachment: fixed !important;
}

#backtoblog{
	display:none !important;
	}

.login form {
    margin-top: 20px !important;
    padding: 16px 17px 18px !important;
    background: #fff !important;
    -webkit-box-shadow: 0 1px 3px rgba(0,0,0,.13) !important;
    box-shadow: 0px 0px 0px 0px rgba(0,0,0,.13) !important;
}

.login #nav {
    margin: 10px 0 0 !important;
}
.login #backtoblog, .login #nav {
    padding: 0px !important;
}




#nav a {
	-moz-box-shadow:inset 0px -3px 7px 0px #29bbff;
	-webkit-box-shadow:inset 0px -3px 7px 0px #29bbff;
	box-shadow:inset 0px -3px 7px 0px #29bbff;
	background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #2dabf9), color-stop(1, #0688fa));
	background:-moz-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
	background:-webkit-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
	background:-o-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
	background:-ms-linear-gradient(top, #2dabf9 5%, #0688fa 100%);
	background:linear-gradient(to bottom, #2dabf9 5%, #0688fa 100%);
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#2dabf9', endColorstr='#0688fa',GradientType=0);
	background-color:#2dabf9;
	-moz-border-radius:3px;
	-webkit-border-radius:3px;
	border-radius:3px;
	display:inline-block;
	cursor:pointer;
	color:#ffffff !important;
	font-family:Arial;
	padding:2px 10px;
	text-decoration:none;
	text-shadow:0px 1px 0px #263666;
}
#nav a:hover {
	background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0688fa), color-stop(1, #2dabf9));
	background:-moz-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
	background:-webkit-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
	background:-o-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
	background:-ms-linear-gradient(top, #0688fa 5%, #2dabf9 100%);
	background:linear-gradient(to bottom, #0688fa 5%, #2dabf9 100%);
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0688fa', endColorstr='#2dabf9',GradientType=0);
	background-color:#0688fa;
}
#nav a:active {
	position:relative;
	top:1px;
}
.login label {
    color: #000000 !important;
    font-size: 12px !important;
}
.wp-core-ui .button-primary {
	-moz-box-shadow:inset 0px 39px 0px -24px #e67a73 !important;
	-webkit-box-shadow:inset 0px 39px 0px -24px #e67a73 !important;
	box-shadow:inset 0px 39px 0px -24px #e67a73 !important;
	background-color:#e4685d !important;
	-moz-border-radius:4px;
	-webkit-border-radius:4px;
	border-radius:4px;
	border:1px solid #ffffff !important;
	display:inline-block;
	cursor:pointer;
	color:#ffffff;
	font-family:Arial;
	font-size:17px !important;
	padding:6px 15px;
	text-decoration:none;
	text-shadow:0px 1px 0px #b23e35 !important;
	
}
.wp-core-ui .button-primary:hover {
	background-color:#eb675e !important;
}
.wp-core-ui .button-primary:active {
	position:relative;
	top:1px;
}

#loginform p label #user_login, #loginform p label #user_pass { 
font-weight: normal;
padding: 8px 9px;
font-style: normal;
border-right-color: #dadada;
border-bottom-color: #dadada;
color: #999 !important;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
outline: none;
text-shadow: 0px 1px 0px #fff;
background-color: #fff;
background: -webkit-gradient(linear, left top, left bottombottom, from(#f9f9f9), to(#ffffff)) !important;
background: -webkit-linear-gradient(top, #f9f9f9, #ffffff) !important;  
background: -moz-linear-gradient(top,  #f9f9f9,  #ffffff) !important;
background: -ms-linear-gradient(top, #f9f9f9, #ffffff) !important;
background: -o-linear-gradient(top, #f9f9f9, #ffffff);
}

#loginform p label #user_login:focus, #loginform p label #user_pass:focus, #loginform p label #user_login:hover, #loginform p label #user_pass:hover { 
	color: #777 !important;
	background: #fff !important;
}

#loginform p label #user_login:-webkit-autofill, #loginform p label #user_pass:-webkit-autofill {
	background-color: #fff !important;
}

#login h1 { display: block; position: relative; height: 99px; margin-top: 10px; }
#login h1 a {
    background: #fff url('logo.png') no-repeat top center;
    display: block;
    position: relative;
    right: 55px;
    top: -50px;
    width: 419px;
    height: 160px;
}

Javascript и работа с Media Library на WordPress

  • 1
afilipov
четвъртък, 23 юни 2016 / Published in Wordpress

В примера по-долу извиквам Media Library на WordPress, чрез натискане на картинка.

<script>

function getmedia(ident){
	
    // Instantiates the variable that holds the media library frame.
    var meta_image_frame;

    // Runs when the image button is clicked.
	
    j(function(){

        // Prevents the default action from occuring.
      //  e.preventDefault();

        // If the frame already exists, re-open it.
        if ( meta_image_frame ) {
            meta_image_frame.open();
            return;
        }

        // Sets up the media library frame
        meta_image_frame = wp.media.frames.meta_image_frame = wp.media({
          //  title: meta_image.title,
         //   button: { text:  meta_image.button },
            library: { type: 'image' }
        });

        // Runs when an image is selected.
        meta_image_frame.on('select', function(){

          //  return false;

            // Grabs the attachment selection and creates a JSON representation of the model.
            var media_attachment = meta_image_frame.state().get('selection').first().toJSON();

            // Sends the attachment URL to our custom image input field.
			
					
	document.getElementById("imgc_"+ident).src = media_attachment.sizes.thumbnail.url;
			
        //media_attachment.id; 	имате и id-то на самият attachment (за повече опции, проверете в WordPress документацията)

			
        });

        // Opens the media library frame.
        meta_image_frame.open();
    });

	 
	 
	 
}

  </script>

Ето това са картинките, чрез които ще извикваме Media Library и ще заменяме src адреса.

<img src="smiley.gif" id="imgc_1" alt="Smiley face" height="42" width="42" onclick="getmedia('1');"></br>
<img src="smiley.gif" id="imgc_2" alt="Smiley face" height="42" width="42" onclick="getmedia('2');"></br>
<img src="smiley.gif" id="imgc_3" alt="Smiley face" height="42" width="42" onclick="getmedia('3');">

Как да създадем допълнителни полета „Custom Meta Fields“ в „Taxonomies“

  • 0
afilipov
неделя, 19 юни 2016 / Published in Wordpress
<?php
// Add term page
function pippin_taxonomy_add_new_meta_field() {
	// this will add the custom meta field to the add new term page
	?>
	<div class="form-field">
		<label for="term_meta[custom_term_meta]"><?php _e( 'Example meta field', 'pippin' ); ?></label>
		<input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="">
		<p class="description"><?php _e( 'Enter a value for this field','pippin' ); ?></p>
	</div>
<?php
}
add_action( 'category_add_form_fields', 'pippin_taxonomy_add_new_meta_field', 10, 2 );

Забележете това: {$taxonomy_name}_add_form_fields !

След като сте поставили кода би трябвало да виждате следното нещо:

taxonomy-meta

За да направите така, че добавеното от вас поле да има възможността да се редактира е нужно да поставите и кода:

<?php
// Edit term page
function pippin_taxonomy_edit_meta_field($term) {
 
	// put the term ID into a variable
	$t_id = $term->term_id;
 
	// retrieve the existing value(s) for this meta field. This returns an array
	$term_meta = get_option( "taxonomy_$t_id" ); ?>
	<tr class="form-field">
	<th scope="row" valign="top"><label for="term_meta[custom_term_meta]"><?php _e( 'Example meta field', 'pippin' ); ?></label></th>
		<td>
			<input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="<?php echo esc_attr( $term_meta['custom_term_meta'] ) ? esc_attr( $term_meta['custom_term_meta'] ) : ''; ?>">
			<p class="description"><?php _e( 'Enter a value for this field','pippin' ); ?></p>
		</td>
	</tr>
<?php
}
add_action( 'category_edit_form_fields', 'pippin_taxonomy_edit_meta_field', 10, 2 );

Резултата трябва да изглежда така:

taxonomy-meta-edit

Последната стъпка е да направите функцията, която ще запази вашето ново поле в базата:

// Save extra taxonomy fields callback function.
function save_taxonomy_custom_meta( $term_id ) {
	if ( isset( $_POST['term_meta'] ) ) {
		$t_id = $term_id;
		$term_meta = get_option( "taxonomy_$t_id" );
		$cat_keys = array_keys( $_POST['term_meta'] );
		foreach ( $cat_keys as $key ) {
			if ( isset ( $_POST['term_meta'][$key] ) ) {
				$term_meta[$key] = $_POST['term_meta'][$key];
			}
		}
		// Save the option array.
		update_option( "taxonomy_$t_id", $term_meta );
	}
}  
add_action( 'edited_category', 'save_taxonomy_custom_meta', 10, 2 );  
add_action( 'create_category', 'save_taxonomy_custom_meta', 10, 2 );

Създаване на „Taxonomies“ в WordPress

  • 0
afilipov
неделя, 19 юни 2016 / Published in Wordpress
$labels = array(
    'name' => _x( 'Categories', 'taxonomy general name' ),
    'singular_name' => _x( 'Category', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Categories' ),
    'all_items' => __( 'All Categories' ),
    'parent_item' => __( 'Parent Category' ),
    'parent_item_colon' => __( 'Parent Category:' ),
    'edit_item' => __( 'Edit Category' ), 
    'update_item' => __( 'Update Category' ),
    'add_new_item' => __( 'Add Category' ),
    'new_item_name' => __( 'New Category' ),
    'menu_name' => __( 'Categories' )
);
 
register_taxonomy('portfolio_categories',array('portfolio'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'query_var' => true,
    'show_ui' => true
));
 
add_filter('manage_edit-portfolio_categories_columns', 'add_portfolio_categories_column' );

‘hierarchical’ => true -> makes a difference between checkboxes and autosuggest

Създаване на „Custom post types“ в WordPress

  • 0
afilipov
неделя, 19 юни 2016 / Published in Wordpress

Влезте в папката на вашата тема и отворете файла functions.php.
Извикайте файла city.php.

require_once ('functions/city.php');

city.php

add_action( 'init', 'city_register');
 
function city_register() {
    $labels = array(
        'name' => _x('Cities', 'post type general name'),
        'singular_name' => _x('City', 'post type singular name'),
        'add_new' => _x('Add New', 'City'),
        'add_new_item' => __('Add New City'),
        'edit_item' => __('Edit City'),
        'new_item' => __('New City'),
        'all_items' => __('All Cities'),
        'view_item' => __('View Cities'),
        'search_items' => __('Search Cities'),
        'not_found' =>  __('No cities found'),
        'not_found_in_trash' => __('No cities found in Trash'), 
        'parent_item_colon' => '',
        'menu_name' => 'Cities'
     );
 
     $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true, 
        'show_in_menu' => true, 
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
        'menu_icon' => 'dashicons-flag'
     ); 
     register_post_type('city', $args);
}

След като вече сте създали новия тип постове, може да го извикате в предната част на сайта по следният начин:

template-city.php

<?php
$args = array( 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order'=>'ASC', 'post_type' => 'city');
query_posts($args);
$lastposts = get_posts( $args );
?>
 
<?php
foreach ( $lastposts as $post ) :
    $post_orig = $post;
    setup_postdata( $post ); ?>
 
    <div class="city">
        <h3><?php the_title(); ?></h3>
        <div class="thumb">
            <?php the_post_thumbnail(array(500, 500)); ?>
        </div>
        <?php the_content(); ?>   
    </div>
<?php endforeach; ?>
 
 
 
<?php wp_reset_postdata();?>
<?php wp_reset_query();?>

Използване на изображенията в WordPress

  • 0
afilipov
неделя, 19 юни 2016 / Published in Wordpress

Влезте във functions.php на вашата тема и първото нещо, което трябва да направите е да включите поддръжката на изображения чрез команда:

add_theme_support('post-thumbnails');

Новият вид изображения се декларират по следният начин:

add_image_size('prod-thumb', 353, 235, true);
add_image_size('prod-thumb-2', 353, 353, true);

Във фронтенд-а викате създадените от системата картинки:

$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), "prod-thumb");

<img src="<?php echo $thumb[0] ?>" alt="" width="<?php echo $thumb[1] ?>" height="<?php echo $thumb[2] ?>" />

Създаване на sidebar в WordPress

  • 0
afilipov
неделя, 19 юни 2016 / Published in Wordpress

Отворете functions.php на вашата тема и поставете следния код:

$i = 1;
$args = array(
    'name'          => "Right sidebar",
    'id'            => "sidebar-$i",
    'description'   => '',
    'class'         => '',
    'before_widget' => '',
    'after_widget'  => "\n",
    'before_title'  => '<h2 class="widgettitle">',
    'after_title'   => "</h2>\n",
);
register_sidebar( $args );

По този начин може да декларирате колкото ви трябват sidebars.

Визуализацията във фронтенд-а става чрез следната функция:

<?php
dynamic_sidebar( 'sidebar-1' );
?>

Качване на файлове в WordPress Media Library използвайки PHP

  • 0
afilipov
неделя, 19 юни 2016 / Published in Wordpress
<form method="post" action="" enctype="multipart/form-data">
 
    <p>
        <input type="file" name="myfile" id="myfile" />
    </p>
 
    <p><input type="submit" value="Uploaden" id="submit" name="submit" class="submit" /></p>
 
</form>
// https://cube3x.com/upload-files-to-wordpress-media-library-using-php/
if(@$_FILES['myfile']['size']){
    if ( ! function_exists( 'wp_handle_upload' ) ) require_once( ABSPATH . 'wp-admin/includes/file.php' );
    if ( ! function_exists( 'wp_generate_attachment_metadata' ) ) require_once( ABSPATH . 'wp-admin/includes/image.php' );
    $uploadedfile = $_FILES['myfile'];
    if($uploadedfile){
        $upload_overrides = array( 'test_form' => false );
        $movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
        if ( $movefile ) {
            $post = array(
                'post_title' => time(),
                'post_content' => '',
                'post_status' => 'publish',
                'post_type' => 'card'
            );
            $upload_post_id = wp_insert_post($post);
            do_action('wp_insert_post', 'wp_insert_post'); 
 
            $wp_filetype = $movefile['type'];
            $filename = $movefile['file'];
            $wp_upload_dir = wp_upload_dir();
            $attachment = array(
                'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),
                'post_mime_type' => $wp_filetype,
                'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
                'post_content' => '',
                'post_status' => 'inherit'
            );
            $attach_id = wp_insert_attachment( $attachment, $filename, $upload_post_id);
            $attach_data = wp_generate_attachment_metadata($attach_id, $filename);
            //dump($attach_data); die;
            wp_update_attachment_metadata($attach_id, $attach_data);
            set_post_thumbnail( $upload_post_id, $attach_id);
            if($attach_id) header("Location: ".get_permalink(PAGE_ID_EXAMPLE));
        }
    }
}

Как да спрем автоматичния ъпдейт в WordPress?

  • 0
afilipov
неделя, 19 юни 2016 / Published in Wordpress

Влезте в главната директория на WordPress и във файла wp-config.php напишете следното:

<?php
    define('WP_AUTO_UPDATE_CORE', false);
?>

Как да оптимизираме скоростта на WordPress чрез конфигуриране на кеша на браузера в .htaccess файла

  • 0
afilipov
петък, 03 юни 2016 / Published in Wordpress, Код оптимизация

Първо спираме ETag header-а тъй като ще използваме EXPIRES CACHING:

# ----------------------------------------------------------------------
# Expire Header
# ----------------------------------------------------------------------

# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset UTF-8
# Force UTF-8 for a number of file formats

AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml


# FileETag None is not enough for every server.

Header unset ETag


# Since we’re sending far-future expires, we don’t need ETags for static content.
# developer.yahoo.com/performance/rules.html#etags
FileETag None

# Send CORS headers if browsers request them; enabled by default for images.


# mod_headers, y u no match by Content-Type?!

SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS




# Allow access to web fonts from all domains.


Header set Access-Control-Allow-Origin "*"






Header set X-Powered-By "WP Rocket/2.8.14"
Header unset Pragma
Header append Cache-Control "public"
Header unset Last-Modified





Header unset Pragma
Header append Cache-Control "public"




# Expires headers (for better cache control)

ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault                          "access plus 1 month"

# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest       "access plus 0 seconds"

# Your document html
ExpiresByType text/html                 "access plus 0 seconds"

# Data
ExpiresByType text/xml                  "access plus 0 seconds"
ExpiresByType application/xml           "access plus 0 seconds"
ExpiresByType application/json          "access plus 0 seconds"

# Feed
ExpiresByType application/rss+xml       "access plus 1 hour"
ExpiresByType application/atom+xml      "access plus 1 hour"

# Favicon (cannot be renamed)
ExpiresByType image/x-icon              "access plus 1 week"

# Media: images, video, audio
ExpiresByType image/gif                 "access plus 1 month"
ExpiresByType image/png                 "access plus 1 month"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType video/ogg                 "access plus 1 month"
ExpiresByType audio/ogg                 "access plus 1 month"
ExpiresByType video/mp4                 "access plus 1 month"
ExpiresByType video/webm                "access plus 1 month"

# HTC files  (css3pie)
ExpiresByType text/x-component          "access plus 1 month"

# Webfonts
ExpiresByType application/x-font-ttf    "access plus 1 month"
ExpiresByType font/opentype             "access plus 1 month"
ExpiresByType application/x-font-woff   "access plus 1 month"
ExpiresByType application/x-font-woff2  "access plus 1 month"
ExpiresByType image/svg+xml             "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

# CSS and JavaScript
ExpiresByType text/css                  "access plus 1 year"
ExpiresByType application/javascript    "access plus 1 year"



# Gzip compression

# Active compression
SetOutputFilter DEFLATE
# Force deflate for mangled headers


SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
# Don’t compress images and other uncompressible content
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g|mp4|webm|webp)$ no-gzip dont-vary



# Compress all output labeled with one of the following MIME-types

AddOutputFilterByType DEFLATE application/atom+xml \
		                          application/javascript \
		                          application/json \
		                          application/rss+xml \
		                          application/vnd.ms-fontobject \
		                          application/x-font-ttf \
		                          application/xhtml+xml \
		                          application/xml \
		                          font/opentype \
		                          image/svg+xml \
		                          image/x-icon \
		                          text/css \
		                          text/html \
		                          text/plain \
		                          text/x-component \
		                          text/xml


Header append Vary: Accept-Encoding



# ----------------------------------------------------------------------
# Fonts
# ----------------------------------------------------------------------
# Add correct content-type for fonts 
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType font/x-woff .woff
AddType image/svg+xml .svg
# Compress compressible fonts
AddOutputFilterByType DEFLATE font/ttf font/otf image/svg+xml
# Add a far future Expires header for fonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/x-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"




Remove Query Strings

Добавете следния код в function.php (WordPress)

function _remove_script_version( $src ){
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
  • 2
  • 3
  • 4
  • 5

Търсене

Категории

  • CSS
  • SEO Оптимизация
  • WooCommerce
  • Wordpress
  • WordPress Модули
  • Код оптимизация
  • Трикове

Архиви

  • февруари 2026
  • юли 2020
  • юли 2018
  • февруари 2018
  • август 2017
  • март 2017
  • ноември 2016
  • октомври 2016
  • септември 2016
  • август 2016
  • юли 2016
  • юни 2016
  • май 2016
  • март 2016
  • юли 2012

УСЛУГИ

ВРЪЗКА С НАС

(+359) 888 898 797
Email: office@ait-webdesign.com

AIT WEB DESIGN
6300 Хасково, Ул. Хан Аспарух 9-11. България

Отвори в Google Maps

ПОСЛЕДНО ЗАВЪРШЕНИ ПРОЕКТИ

Етикети

  • НАЧАЛО
  • Услуги

Всички права запазени AIT WEB DESIGN 2026

НАГОРЕ