Providec
Forum Replies Created
-
Ок, я понял.
P.S. Английский не проблема, на данном этапе, просто был уверен, что на русском общаться было бы роднее и понятнее, видимо ошибался…
Александр, я в любом случае полезу в ваш плагин и буду реализовывать возможности, оговоренные в начале темы. Вопрос только в том, нужны ли вам результаты моего труда или нет?
Если нужны, то вы можете сильно облегчить мне жизнь, указав как именно проще всего это сделать. При этом вы можете составить список требований согласно которых нужно все оформить. Если я чего-то не знаю, то это не повод для размышлений, мне ничего не стоит научиться чему-то новому.
Если же нет, то ради бога, просто я потрачу немного больше времени …
Сейчас уезжаю на отдых, поэтому буду выходить на связь по возможности, поэтому жду от вас предметных решений.Alexander, I will climb into your plugin and I will realize the possibilities specified in the beginning of the topic. The only question is whether you need the results of my work or not?
If desired, you can simplify my life by putting in how exactly the easiest thing to do. With this you can make a list of requirements according to which you need to arrange everything. If I don’t know something, it is not an occasion for thought, I could learn something new.
If not, then for God’s sake, I’ll just spend a little more time …
Now leaving on vacation, so I will be communicating as possible, so I expect you to subject decisions.По первым трём пунктам не пользовался никогда, т.е. знаю что это, но сам не пользовался этим. По поводу хуков – add_action, add_filter – в курсе, что грубо говоря это возможность изменения одной из базовых функций, что собственно и реализовано в приведенных мной выше примерах. Примеры не от балды, они реально используются и не содраны откуда-то бездумно. Вы сами можете в этом убедиться, посетив сайт и посмотрев на структуру (profiapple.ru).
The first three paragraphs would not ever, i.e. know what it is, but I do not use it. About hooks – add_action, add_filter – know that roughly speaking is the ability to change a basic function that is actually implemented in the above examples. Examples are not from the bulldozer, they are actually used and not ripped off from somewhere mindlessly. You can verify this by visiting the website and looking at the structure (profiapple.ru).
Некоторые функции из сайта profiapple.ru
// Формируем свой тип записей function add_custom_post_type($add_type, $add_args = false, $add_labels = false) { $post_type = mb_strtolower($add_type); $labels = array( 'name' => $add_type, 'singular_name' => $add_type, 'add_new' => 'Добавить статью', 'add_new_item' => 'Добавить новую статью', 'edit_item' => 'Редактировать статью', 'new_item' => 'Новая статья ('.$add_type.')', 'all_items' => 'Список статей', 'view_item' => 'Просмотреть страницу статьи', 'search_items' => 'Найти статью', 'not_found' => 'Такой статьи не найдено', 'not_found_in_trash' => 'Статей в корзине не найдено', 'parent_item_colon' => '', 'menu_name' => $add_type ); if(is_array($add_labels)) { foreach ($add_labels as $key=>$val) $labels[$key] = $val; } $args = array( 'label' => $add_type, 'labels' => $labels, 'description' => 'Рубрика про '.$add_type, 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'menu_position' => null, 'menu_icon' => null, 'capability_type' => 'post', 'supports' => array('title','editor','thumbnail','custom-fields','comments'), 'taxonomies' => array('category'), 'hierarchical' => false, 'has_archive' => true, 'rewrite' => false, 'query_var' => true ); if(is_array($add_args)) { foreach ($add_args as $key=>$val) $args[$key] = $val; } register_post_type($post_type, $args ); } // Формируем свой тип урлов function add_custom_permalink($permalink, $post_id, $leavename) { $post = get_post($post_id); $rewritecode = '%category%'; if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) { $my_link = ''; if ( strpos($permalink, $rewritecode) !== false ) { $cats = get_the_terms($post->ID, 'category'); if ($cats) { usort($cats, '_usort_terms_by_ID'); // order by ID $parent = $cats[0]->parent; $my_link = $cats[0]->slug; while ($parent != 0) { $pcats = get_term_by('id', $parent, 'category'); $parent = $pcats->parent; $my_link = $pcats->slug.'/'.$my_link; } } } $permalink = str_replace($rewritecode, $my_link, $permalink); } return $permalink; } // Добавляем свой список продукции Apple function add_list_of_apple_product() { global $wp_rewrite; $list = array ( 'iPhone' => array ( 'args' => array ('menu_position' => 4, 'menu_icon' => 'dashicons-smartphone' ), 'labels' => array() ), 'iPad' => array ( 'args' => array ('menu_position' => 4, 'menu_icon' => 'dashicons-tablet' ), 'labels' => array() ), 'iPod' => array ( 'args' => array ('menu_position' => 4, 'menu_icon' => 'dashicons-media-audio' ), 'labels' => array() ), 'iOs' => array ( 'args' => array ('menu_position' => 4, 'menu_icon' => 'dashicons-shield' ), 'labels' => array() ), 'Sidebar' => array ( 'args' => array ('exclude_from_search' => true, 'show_in_menu' => false, 'show_in_nav_menus' => false ), 'labels' => array() ) ); foreach ($list as $key=>$val) { $post_type = mb_strtolower($key); add_custom_post_type($key, $val['args'], $val['labels']); $structure = '/'.$post_type.'/%category%/%'.$post_type.'%.html'; $wp_rewrite->add_rewrite_tag("%".$post_type."%", '([^/]+)', $post_type."="); $wp_rewrite->add_permastruct($post_type, $structure, false); add_filter('post_type_link', 'add_custom_permalink', 10, 3); } } add_action('init', 'add_list_of_apple_product'); // Фильтр вывода записей в категориях global $device_list; $device_list = array('Post' => 'post', 'iPhone' => 'iphone', 'iPad' => 'ipad', 'iPod' => 'ipod', 'iOS' => 'ios'); function custom_post_queries( $query ) { global $device_list; if (!is_admin() && $query->is_main_query() && (is_home() || is_category())){ $device = (isset($_GET['device']) && !empty($_GET['device'])) ? $_GET['device'] : 'Default' ; if($device != 'Default') { foreach ($device_list as $k=>$v) { if ($device == $k) { $query->set ('post_type', array($v)); break; } } } else { $query->set ('post_type', $device_list); } } } add_action( 'pre_get_posts', 'custom_post_queries' );function CheckUploadedImage($BigPatch) { // Проверка размера изображения if($_FILES["my-pictures"]["size"] > 2*1024*1024){ $request['response'] = 0; $request['data'] = _('The file size is greater than two megabytes'); return $request; } if(is_uploaded_file($_FILES["my-pictures"]["tmp_name"])) { $valid_types = array("jpg", "png", "jpeg"); if(!move_uploaded_file($_FILES["my-pictures"]["tmp_name"], $BigPatch)) { $request['response'] = 0; $request['data'] = sprintf(_('Error loading file %s'), $_FILES["my-pictures"]["name"]); return $request; } $img_extention = mb_strtolower(getExtension($BigPatch)); // Проверка на принадлежность к изображению if(!in_array($img_extention, $valid_types)) { unlink($BigPatch); $request['response'] = 0; $request['data'] = sprintf(_('The file %s is not supported'), $_FILES["my-pictures"]["name"]); return $request; } // Проверка разрешения изображения $size = getimagesize($BigPatch); if($size[0] > 2500 || $size[1] > 2000) { unlink($BigPatch); $request['response'] = 0; $request['data'] = sprintf(_('The file %s is very large. His resolution - %sx%s pixels.'), $_FILES["my-pictures"]["name"], $size[0], $size[1]); $request['data'] .= _('Upload image, whose resolution is 2500x2000 pixels.'); return $request; } // Попытка конвертировать изображение if($img_extention == 'png') { if (!PNG_to_JPG($BigPatch, $BigPatch, '100')) { unlink($BigPatch); $request['response'] = 0; $request['data'] = sprintf(_('Failed to convert file %s'), $_FILES["my-pictures"]["name"]); return $request; } } } else { $request['response'] = 0; $request['data'] = _('Error loading file!'); return $request; } return array('response'=>1); }http://onlinezakladki.ru/ – мой сайт.
http://profiapple.ru/ – пример на WordPress также мой сайт
http://i-like-psy.ru/movies/ – еще один WordPress для которого и строю тесты.Можете продублировать последнее сообщение по русски, т.к. не все понятно? Опыт есть, в том числе и по Вордпресс, пример кода скину, только куда?
Интерфейс естественно тоже доработаю, по поводу тестов не понял ….Can duplicate last post in English, because not everything is clear? The experience there, including WordPress, example code skeen, only where?
The interface is of course also drawbacks, about the tests not understand….А можете как-то намекнуть на принцип более простого воплощения этой идеи, вы ведь лучше знаете свой код? Я тогда сам попробую дописать функционал и по итогу скину вам результат для проверки и добавления в плагин. Другими словами я готов поучавствовать в доработке.
Can You somehow hint at the principle than the simple realization of this idea, because you better know your code. I’ll try to add functionality and will send you’ll the result to check and add it to the plugin. In other words I am ready to participate in the programming.
Ready)