set( 'author', $current_user->id );
28 |
29 | // add an action here so we can execute other functions
30 | do_action('omyp_restricting_by_author');
31 | }
32 | }
33 | }
34 |
35 | /**
36 | * omyp_parse_query_useronly add css for the show only one users' posts interface
37 | * @since 0.2
38 | */
39 | function omyp_useronly_assets( )
40 | {
41 | // add some css
42 | wp_register_style( 'omyp_useronly_styles', plugins_url('assets/style.css', __FILE__) );
43 | wp_enqueue_style( 'omyp_useronly_styles' );
44 | }
45 |
46 | add_filter('parse_query', 'omyp_parse_query_useronly' );
47 | add_action('omyp_restricting_by_author', 'omyp_useronly_assets')
48 | ?>
49 |
--------------------------------------------------------------------------------
/plugins2/posts_order_fix.php:
--------------------------------------------------------------------------------
1 | '1,2,3,', //(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => '-1,-2,-3,']
15 | 'author_name' => 'luetkemj', //(string) - use 'user_nicename' (NOT name)
16 | 'author__in' => array( 2, 6 ), //(array) - use author id (available with Version 3.7).
17 | 'author__not_in' => array( 2, 6 ), //(array)' - use author id (available with Version 3.7).
18 |
19 | //////Category Parameters - Show posts associated with certain categories.
20 | //http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
21 | 'cat' => 5,//(int) - use category id.
22 | 'category_name' => 'staff, news', //(string) - Display posts that have these categories, using category slug.
23 | 'category_name' => 'staff+news', //(string) - Display posts that have "all" of these categories, using category slug.
24 | 'category__and' => array( 2, 6 ), //(array) - use category id.
25 | 'category__in' => array( 2, 6 ), //(array) - use category id.
26 | 'category__not_in' => array( 2, 6 ), //(array) - use category id.
27 |
28 | //////Tag Parameters - Show posts associated with certain tags.
29 | //http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
30 | 'tag' => 'cooking', //(string) - use tag slug.
31 | 'tag_id' => 5, //(int) - use tag id.
32 | 'tag__and' => array( 2, 6), //(array) - use tag ids.
33 | 'tag__in' => array( 2, 6), //(array) - use tag ids.
34 | 'tag__not_in' => array( 2, 6), //(array) - use tag ids.
35 | 'tag_slug__and' => array( 'red', 'blue'), //(array) - use tag slugs.
36 | 'tag_slug__in' => array( 'red', 'blue'), //(array) - use tag slugs.
37 |
38 | //////Taxonomy Parameters - Show posts associated with certain taxonomy.
39 | //http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
40 | //Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
41 | //This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
42 | 'tax_query' => array( //(array) - use taxonomy parameters (available with Version 3.1).
43 | 'relation' => 'AND', //(string) - Possible values are 'AND' or 'OR' and is the equivalent of running a JOIN for each taxonomy
44 | array(
45 | 'taxonomy' => 'color', //(string) - Taxonomy.
46 | 'field' => 'slug', //(string) - Select taxonomy term by ('id' or 'slug')
47 | 'terms' => array( 'red', 'blue' ), //(int/string/array) - Taxonomy term(s).
48 | 'include_children' => true, //(bool) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
49 | 'operator' => 'IN' //(string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND'.
50 | ),
51 | array(
52 | 'taxonomy' => 'actor',
53 | 'field' => 'id',
54 | 'terms' => array( 103, 115, 206 ),
55 | 'include_children' => false,
56 | 'operator' => 'NOT IN'
57 | )
58 | ),
59 |
60 | //////Post & Page Parameters - Display content based on post and page parameters.
61 | //http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
62 | 'p' => 1, //(int) - use post id.
63 | 'name' => 'hello-world', //(string) - use post slug.
64 | 'page_id' => 1, //(int) - use page id.
65 | 'pagename' => 'sample-page', //(string) - use page slug.
66 | 'pagename' => 'contact_us/canada', //(string) - Display child page using the slug of the parent and the child page, separated ba slash
67 | 'post_parent' => 1, //(int) - use page id. Return just the child Pages. (Only works with heirachical post types.)
68 | 'post_parent__in' => array(1,2,3) //(array) - use post ids. Specify posts whose parent is in an array. NOTE: Introduced in 3.6
69 | 'post_parent__not_in' => array(1,2,3), //(array) - use post ids. Specify posts whose parent is not in an array.
70 | 'post__in' => array(1,2,3), //(array) - use post ids. Specify posts to retrieve. ATTENTION If you use sticky posts, they will be included (prepended!) in the posts you retrieve whether you want it or not. To suppress this behaviour use ignore_sticky_posts
71 | 'post__not_in' => array(1,2,3), //(array) - use post ids. Specify post NOT to retrieve.
72 | //NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query
73 |
74 | //////Password Parameters - Show content based on post and page parameters. Remember that default post_type is only set to display posts but not pages.
75 | //http://codex.wordpress.org/Class_Reference/WP_Query#Password_Parameters
76 | 'has_password' => true, //(bool) - available with Version 3.9
77 | //true for posts with passwords;
78 | //false for posts without passwords;
79 | //null for all posts with and without passwords
80 | 'post_password' => 'multi-pass', //(string) - show posts with a particular password (available with Version 3.9)
81 |
82 | //////Type & Status Parameters - Show posts associated with certain type or status.
83 | //http://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters
84 | 'post_type' => array( //(string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
85 | 'post', // - a post.
86 | 'page', // - a page.
87 | 'revision', // - a revision.
88 | 'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but atchments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
89 | 'my-post-type', // - Custom Post Types (e.g. movies)
90 | ),
91 | //NOTE: The 'any' keyword available to both post_type and post_status queries cannot be used within an array.
92 | 'post_type' => 'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.
93 |
94 | //////Type & Status Parameters - Show posts associated with certain type or status.
95 | //http://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters
96 | 'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value i'publish'.
97 | 'publish', // - a published post or page.
98 | 'pending', // - post is pending review.
99 | 'draft', // - a post in draft status.
100 | 'auto-draft', // - a newly created post, with no content.
101 | 'future', // - a post to publish in the future.
102 | 'private', // - not visible to users who are not logged in.
103 | 'inherit', // - a revision. see get_children.
104 | 'trash' // - post is in trashbin (available with Version 2.9).
105 | ),
106 | //NOTE: The 'any' keyword available to both post_type and post_status queries cannot be used within an array.
107 | 'post_status' => 'any', // - retrieves any status except those from post types with 'exclude_from_search' set to true.
108 |
109 |
110 |
111 | //////Pagination Parameters
112 | //http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
113 | 'posts_per_page' => 10, //(int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page' => -1 to show all posts.
114 | //Note: if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. Treimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
115 | 'posts_per_archive_page' => 10, //(int) - number of posts to show per page - on archive pages only. Over-rides showposts anposts_per_page on pages where is_archive() or is_search() would be true
116 | 'nopaging' => false, //(bool) - show all posts or use pagination. Default value is 'false', use paging.
117 | 'paged' => get_query_var('paged'), //(int) - number of page. Show the posts that would normally show up just on page X when usinthe "Older Entries" link.
118 | //NOTE: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The query variable 'page' holds the pagenumber for a single paginated Post or Page that includes the Quicktag in the post content.
119 |
120 |
121 |
122 | 'nopaging' => false, // (boolean) - show all posts or use pagination. Default value is 'false', use paging.
123 | 'posts_per_archive_page' => 10, // (int) - number of posts to show per page - on archive pages only. Over-rides posts_per_page and showposts on pages where is_archive() or is_search() would be true.
124 | 'offset' => 3, // (int) - number of post to displace or pass over.
125 | // Warning: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination. for a workaround see: http://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
126 | // The 'offset' parameter is ignored when 'posts_per_page'=>-1 (show all posts) is used.
127 | 'paged' => get_query_var('paged'), //(int) - number of page. Show the posts that would normally show up just on page X when usinthe "Older Entries" link.
128 | //NOTE: This whole paging thing gets tricky. Some links to help you out:
129 | // http://codex.wordpress.org/Function_Reference/next_posts_link#Usage_when_querying_the_loop_with_WP_Query
130 | // http://codex.wordpress.org/Pagination#Troubleshooting_Broken_Pagination
131 | 'page' => get_query_var('page'), // (int) - number of page for a static front page. Show the posts that would normally show up just on page X of a Static Front Page.
132 | //NOTE: The query variable 'page' holds the pagenumber for a single paginated Post or Page that includes the Quicktag in the post content.
133 | 'ignore_sticky_posts' => false, // (boolean) - ignore sticky posts or not (available with Version 3.1, replaced caller_get_posts parameter). Default value is 0 - don't ignore sticky posts. Note: ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.
134 |
135 | //////Order & Orderby Parameters - Sort retrieved posts.
136 | //http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
137 | 'order' => 'DESC', //(string) - Designates the ascending or descending order of the 'orderby' parameter. Default to 'DESC'.
138 | //Possible Values:
139 | //'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
140 | //'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
141 | 'orderby' => 'date', //(string) - Sort retrieved posts by parameter. Defaults to 'date'. One or more options can be passed. EX: 'orderby' => 'menu_order title'
142 | //Possible Values:
143 | //'none' - No order (available with Version 2.8).
144 | //'ID' - Order by post id. Note the captialization.
145 | //'author' - Order by author.
146 | //'title' - Order by title.
147 | //'name' - Order by post name (post slug).
148 | //'date' - Order by date.
149 | //'modified' - Order by last modified date.
150 | //'parent' - Order by post/page parent id.
151 | //'rand' - Random order.
152 | //'comment_count' - Order by number of comments (available with Version 2.9).
153 | //'menu_order' - Order by Page Order. Used most often for Pages (Order field in the EdiPage Attributes box) and for Attachments (the integer fields in the Insert / Upload MediGallery dialog), but could be used for any post type with distinct 'menu_order' values (theall default to 0).
154 | //'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note alsthat the sorting will be alphabetical which is fine for strings (i.e. words), but can bunexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as yomight naturally expect).
155 | //'meta_value_num' - Order by numeric meta value (available with Version 2.8). Also notthat a 'meta_key=keyname' must also be present in the query. This value allows for numericasorting as noted above in 'meta_value'.
156 | //'title menu_order' - Order by both menu_order AND title at the same time. For more info see: http://wordpress.stackexchange.com/questions/2969/order-by-menu-order-and-title
157 | //'post__in' - Preserve post ID order given in the post__in array (available with Version 3.5).
158 |
159 | //////Date Parameters - Show posts associated with a certain time and date period.
160 | //http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters
161 | 'year' => 2014, //(int) - 4 digit year (e.g. 2011).
162 | 'monthnum' => 4, //(int) - Month number (from 1 to 12).
163 | 'w' => 25, //(int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependenon the "start_of_week" option.
164 | 'day' => 17, //(int) - Day of the month (from 1 to 31).
165 | 'hour' => 13, //(int) - Hour (from 0 to 23).
166 | 'minute' => 19, //(int) - Minute (from 0 to 60).
167 | 'second' => 30, //(int) - Second (0 to 60).
168 | 'm' => 201404, //(int) - YearMonth (For e.g.: 201307).
169 |
170 | 'date_query' => array( //(array) - Date parameters (available with Version 3.7).
171 | //these are super powerful. check out the codex for more comprehensive code examples http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters
172 | array(
173 | 'year' => 2014, //(int) - 4 digit year (e.g. 2011).
174 | 'month' => 4 //(int) - Month number (from 1 to 12).
175 | 'week' => 31 //(int) - Week of the year (from 0 to 53).
176 | 'day' => 5 //(int) - Day of the month (from 1 to 31).
177 | 'hour' => 2 //(int) - Hour (from 0 to 23).
178 | 'minute' => 3 //(int) - Minute (from 0 to 59).
179 | 'second' => 36 //(int) - Second (0 to 59).
180 | 'after' => 'January 1st, 2013', //(string/array) - Date to retrieve posts after. Accepts strtotime()-compatible string, or array of 'year', 'month', 'day'
181 | 'before' => array( //(string/array) - Date to retrieve posts after. Accepts strtotime()-compatible string, or array of 'year', 'month', 'day'
182 | 'year' => 2013, //(string) Accepts any four-digit year. Default is empty.
183 | 'month' => 2, //(string) The month of the year. Accepts numbers 1-12. Default: 12.
184 | 'day' => 28, //(string) The day of the month. Accepts numbers 1-31. Default: last day of month.
185 | ),
186 | 'inclusive' => true, //(boolean) - For after/before, whether exact value should be matched or not'.
187 | 'compare' => '=', //(string) - Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'EXISTS' (only in WP >= 3.5), and 'NOT EXISTS' (also only in WP >= 3.5). Default value is '='
188 | 'column' => 'post_date', //(string) - Column to query against. Default: 'post_date'.
189 | 'relation' => 'AND', //(string) - OR or AND, how the sub-arrays should be compared. Default: AND.
190 | ),
191 | ),
192 |
193 | //////Custom Field Parameters - Show posts associated with a certain custom field.
194 | //http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
195 | 'meta_key' => 'key', //(string) - Custom field key.
196 | 'meta_value' => 'value', //(string) - Custom field value.
197 | 'meta_value_num' => 10, //(number) - Custom field value.
198 | 'meta_compare' => '=', //(string) - Operator to test the 'meta_value'. Possible values are '!=', '>', '>=', '<', or ='. Default value is '='.
199 | 'meta_query' => array( //(array) - Custom field parameters (available with Version 3.1).
200 | 'relation' => 'AND', //(string) - Possible values are 'AND', 'OR'. The logical relationship between each inner meta_query array when there is more than one. Do not use with a single inner meta_query array.
201 | array(
202 | 'key' => 'color', //(string) - Custom field key.
203 | 'value' => 'blue' //(string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN') Using WP < 3.9? Check out this page for details: http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
204 | 'type' => 'CHAR', //(string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'. The 'type' DATE works with the 'compare' value BETWEEN only if the date is stored at the format YYYYMMDD and tested with this format.
205 | //NOTE: The 'type' DATE works with the 'compare' value BETWEEN only if the date is stored at the format YYYYMMDD and tested with this format.
206 | 'compare' => '=' //(string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'EXISTS' (only in WP >= 3.5), and 'NOT EXISTS' (also only in WP >= 3.5). Default value is '='.
207 | ),
208 | array(
209 | 'key' => 'price',
210 | 'value' => array( 1,200 ),
211 | 'compare' => 'NOT LIKE'
212 | )
213 | ),
214 |
215 | //////Permission Parameters - Display published posts, as well as private posts, if the user has the appropriate capability:
216 | //http://codex.wordpress.org/Class_Reference/WP_Query#Permission_Parameters
217 | 'perm' => 'readable' //(string) Possible values are 'readable', 'editable'
218 |
219 | //////Caching Parameters
220 | //http://codex.wordpress.org/Class_Reference/WP_Query#Caching_Parameters
221 | //NOTE Caching is a good thing. Setting these to false is generally not advised.
222 | 'cache_results' => true, //(bool) Default is true - Post information cache.
223 | 'update_post_term_cache' => true, //(bool) Default is true - Post meta information cache.
224 | 'update_post_meta_cache' => true, //(bool) Default is true - Post term information cache.
225 |
226 | 'no_found_rows' => false, //(bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order to implement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not to count the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more information see: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions
227 |
228 |
229 | //////Search Parameter
230 | //http://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter
231 | 's' => $s, //(string) - Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
232 | 'exact' => true, //(bool) - flag to make it only match whole titles/posts - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118
233 | 'sentence' => true, //(bool) - flag to make it do a phrase search - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118
234 |
235 | //////Post Field Parameters
236 | //For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Return_Fields_Parameter
237 | //also https://gist.github.com/luetkemj/2023628/#comment-1003542
238 | 'fields' => 'ids' //(string) - Which fields to return. All fields are returned by default.
239 | //Possible values:
240 | //'ids' - Return an array of post IDs.
241 | //'id=>parent' - Return an associative array [ parent => ID, … ].
242 | //Passing anything else will return all fields (default) - an array of post objects.
243 |
244 | //////Filters
245 | //For more information on available Filters see: http://codex.wordpress.org/Class_Reference/WP_Query#Filters
246 |
247 | );
248 |
249 | $args = array(
250 |
251 | 'post_type' => array( 'product',),
252 |
253 | // 'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value i'publish'.
254 | // // 'publish', // - a published post or page.
255 | // // 'pending', // - post is pending review.
256 | // // 'draft', // - a post in draft status.
257 | // // 'auto-draft', // - a newly created post, with no content.
258 | // // 'future', // - a post to publish in the future.
259 | // // 'private', // - not visible to users who are not logged in.
260 | // // 'inherit', // - a revision. see get_children.
261 | // // 'trash' // - post is in trashbin (available with Version 2.9).
262 | // ),
263 | // 'paged' => get_query_var( 'paged' ),
264 | 'posts_per_page' => -1,
265 | );
266 | $the_query = new WP_Query( $args );
267 | // The Loop
268 | global $post;
269 | if ( $the_query->have_posts() ) :
270 | while ( $the_query->have_posts() ) : $the_query->the_post();
271 | var_dump($post->ID);
272 | // $wc_product = new WC_Product( $post->ID );
273 | // var_dump($wc_product->get_price());
274 | endwhile;
275 | endif;
276 | // Reset Post Data
277 | wp_reset_postdata();
278 |
279 |
280 |
281 | //сортировка постов
282 | $wp_query = new WP_Query( apply_filters( 'autozone_autos_arg_content_list', $arr ) );
283 | // foreach ($wp_query->posts as $post) {
284 | // var_dump($post->ID . ' ' . get_post_meta( $post->ID, '_auto_price', true ));
285 | // }
286 | $url = $_SERVER['REQUEST_URI'];
287 | if ( strstr($url, 'order=_auto_price-desc') || strstr($url, 'order=_auto_price-asc') ) {
288 | usort($wp_query->posts,'pix_sort_auto_fun');
289 | }
290 | wp_reset_query();
291 |
292 |
293 |
294 | // параметры по умолчанию
295 | $posts = get_posts( array(
296 | 'numberposts' => 5,
297 | 'category' => 0,
298 | 'orderby' => 'date',
299 | 'order' => 'DESC',
300 | 'include' => array(),
301 | 'exclude' => array(),
302 | 'meta_key' => '',
303 | 'meta_value' =>'',
304 | 'post_type' => 'post',
305 | 'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
306 | ) );
307 |
308 | foreach( $posts as $post ){
309 | setup_postdata($post);
310 | // формат вывода the_title() ...
311 | }
312 | wp_reset_postdata(); // сброс
313 |
314 |
315 |
316 | // add reg wpquery(начинаются с)
317 | $args['meta_key'] = 'apartment-number';
318 | $args['meta_value'] = '^'.stripslashes($input['apartment_number']);
319 | $args['meta_compare'] = 'REGEXP';
320 | $args['post__in'] = '';
321 |
322 |
323 |
324 | // большие запросы
325 | $args = array(
326 | 'post_type' => array('product'),
327 | 'posts_per_page' => 100,
328 | 'paged' => 1,
329 | );
330 | $the_query = new WP_Query($args);
331 | if ($the_query->have_posts()){
332 | while ($the_query->have_posts()): $the_query->the_post();
333 |
334 |
335 | endwhile;
336 | }
337 | wp_reset_query();
338 | if ($the_query->max_num_pages > 1) {
339 | for ($i = 2; $i <= $the_query->max_num_pages; $i++) {
340 | $args = array(
341 | 'post_type' => array('product'),
342 | 'posts_per_page' => 100,
343 | 'paged' => $i,
344 | );
345 | $the_query = new WP_Query($args);
346 | if ($the_query->have_posts()):
347 | while ($the_query->have_posts()): $the_query->the_post();
348 |
349 |
350 | endwhile;
351 | endif;
352 | wp_reset_query();
353 | }
354 | }
355 |
356 |
357 |
358 | // big data, no set global post
359 | $args = array(
360 | 'post_type' => array('product'),
361 | 'posts_per_page' => 100,
362 | );
363 | $the_query = new WP_Query($args);
364 | $the_query->have_posts();
365 | $user_posts = $the_query->posts;
366 |
367 | for ($paged = 1; $paged < $the_query->max_num_pages + 1; $paged++) {
368 | $args['paged'] = $paged;
369 | $the_query = new WP_Query($args);
370 | $the_query->have_posts();
371 | $user_posts = $the_query->posts;
372 | foreach ($user_posts as $key => $u_post) {
373 | if(!array_key_exists($u_post->ID, $marafon_all_rating)){
374 |
375 | }
376 |
377 | }
378 | }
379 |
380 |
381 |
382 |
383 |
384 | // запрос постов рейтинга
385 | function marafon_query_rating($value='')
386 | {
387 | return array(
388 | 'posts_per_page' => 1000,
389 | 'post_type' => 'post',
390 | 'post_status' => 'publish',
391 | 'meta_query' => array(
392 | 'relation' => 'OR',
393 | array(
394 | 'key' => 'marafon_weight_rating',
395 | 'type' => 'DECIMAL',
396 | ),
397 | array(
398 | 'key' => 'is_user_post',
399 | 'value' => '',
400 | 'compare' => '!=',
401 | ),
402 | ),
403 | 'meta_key' => 'marafon_weight_rating',
404 | 'meta_compare' => '>',
405 | 'orderby' => 'meta_value_num',
406 | 'order' => 'DESC',
407 | 'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
408 | );
409 | }
--------------------------------------------------------------------------------
/rc.local/forward.sh:
--------------------------------------------------------------------------------
1 |
2 | #------------------------------------------------------------
3 | # public ip => lxd container
4 | #------------------------------------------------------------
5 |
6 | INET=1.2.3.4
7 | IDEV=eth0
8 |
9 | SERVER=10.9.8.7
10 |
11 | iptables -t nat -A PREROUTING -i $IDEV -d $INET -p tcp --dport 80 -j DNAT --to-destination $SERVER:80
12 | iptables -t nat -A PREROUTING -i $IDEV -d $INET -p tcp --dport 443 -j DNAT --to-destination $SERVER:443
13 |
14 | iptables -t nat -A PREROUTING -i $IDEV -d $INET -p tcp --dport 12345 -j DNAT --to-destination $SERVER:12345
15 |
16 | #------------------------------------------------------------
17 |
--------------------------------------------------------------------------------
/sh/perm.sh:
--------------------------------------------------------------------------------
1 | # Set all directories permissions to 755
2 | find . -type d -exec chmod 755 {} \;
3 |
4 | # Set all files permissions to 644
5 | find . -type f -exec chmod 644 {} \;
6 |
7 | # Set wp-config.php file with 604 permission
8 | sudo chmod 640 wp-config.php
9 |
--------------------------------------------------------------------------------
/sql/change-prefix.awk:
--------------------------------------------------------------------------------
1 | #
2 | # change-predix.awk
3 | #
4 | # v1.0
5 | #
6 |
7 | /cdn_7_/ {
8 | gsub("cdn_7_", "wp_");
9 | }
10 |
11 | /cdn_/ {
12 | gsub("cdn_", "wp_");
13 | }
14 |
15 | 1 {
16 | print $0;
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/sql/innodb.awk:
--------------------------------------------------------------------------------
1 | #
2 | # innodb.awk
3 | #
4 | # v1.0
5 | #
6 |
7 | /ENGINE=MyISAM/ {
8 | gsub("ENGINE=MyISAM", "ENGINE=InnoDB");
9 | }
10 |
11 |
12 | 1 {
13 | print $0;
14 | }
15 |
16 |
17 | #-eof-#
18 |
--------------------------------------------------------------------------------
/sql/sql-splitter.awk:
--------------------------------------------------------------------------------
1 | #
2 | # sql-splitter.awk
3 | #
4 | # v1.0
5 | #
6 |
7 |
8 | BEGIN {
9 | table = "sqlheader";
10 | tablen = 1000;
11 | system("mkdir -p out");
12 | }
13 |
14 |
15 | /Table structure for table `/ {
16 | tablen++;
17 | table = $6;
18 | gsub("`", "", table)
19 | }
20 |
21 |
22 | 1 {
23 | of = "out/" tablen "-" table ".sql";
24 | print $0 > of;
25 | }
26 |
27 |
28 | #-eof-#
29 |
--------------------------------------------------------------------------------
/staging/01/wp-chown.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # 2019-10-24
5 | #
6 |
7 | S=sitename
8 |
9 | cd /var/www/$S
10 |
11 | echo ====== $0 $(date +"%F %T") $(pwd)
12 |
13 |
14 | chown -R www-data:www-data htdocs
15 |
--------------------------------------------------------------------------------
/staging/01/wp-commit.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # 2019-10-24
5 | #
6 |
7 | S=sitename
8 |
9 | F=$S.fossil
10 |
11 | FU=ubuntu
12 | FD=/home/$FU/F
13 |
14 | #-------------------------------------
15 | cd /var/www/$S
16 | mkdir -p conf/nginx-etc
17 | cp /etc/nginx/sites-available/$S conf/nginx-etc/$S
18 | #-------------------------------------
19 |
20 | cd /var/www/$S
21 | ./wp-dump.sh
22 |
23 | #-------------------------------------
24 |
25 | echo ========= $(date +"%F %T") --- $0 --- $(pwd)
26 |
27 | #-------------------------------------
28 |
29 | cd /var/www/$S
30 |
31 | if [ ! -w $FD/$F ]
32 | then
33 |
34 | mkdir -p $FD
35 | fossil new $FD/$F
36 |
37 | fossil open $FD/$F trunk
38 |
39 | fossil set autosync 0
40 | fossil set repo-cksum 1
41 | fossil set manifest 0
42 | fossil set mtime-changes 0
43 | fossil set allow-symlinks 1
44 |
45 | fi
46 |
47 |
48 | #-------------------------------------
49 |
50 | if [ $3 ]
51 | then
52 | echo "$3" > conf/tag.txt
53 | fi
54 |
55 | #-------------------------------------
56 |
57 | fossil addr --dotfiles --ignore "logs/*,/.git/*,*tmp,*sql,*/cache/*"
58 | fossil commit -m "$(hostname) $1 " --no-warnings --delta --allow-fork $2 $3 $4
59 |
60 | #-------------------------------------
61 |
62 | cd /var/www/$S
63 |
64 | chown -R www-data:www-data htdocs
65 |
66 | chown $FU:$FU $FD/$F
67 |
68 | #-------------------------------------
69 | echo --------- $(date +"%F %T")
70 | #-------------------------------------
71 |
72 | #-end-#
73 |
--------------------------------------------------------------------------------
/staging/01/wp-cron.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # 2019-10-24
5 | #
6 |
7 | S=sitename
8 |
9 | cd /var/www/$S
10 |
11 |
12 | echo ====== $0 $(date +"%F %T") $(pwd)
13 |
14 |
15 | WP="wp --path=htdocs --allow-root"
16 |
17 | export HTTP_HOST=localhost
18 |
19 | $WP cron event run --due-now
20 |
--------------------------------------------------------------------------------
/staging/01/wp-dump.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # 2019-10-24
5 | #
6 |
7 | S=sitename
8 |
9 | WP="wp --allow-root --path=../htdocs"
10 |
11 | #-------------------------------------
12 |
13 | echo ========= $(date +"%F %T") --- $0 --- $(pwd)
14 |
15 | #-------------------------------------
16 |
17 | cd /var/www/$S
18 |
19 | mkdir -p tmp db
20 |
21 | cd db
22 |
23 | #-------------------------------------
24 |
25 | KEY=secret.key
26 |
27 | $WP db export - | head -n -1 > full.sql
28 |
29 | test -f full.sec && rm full.sec
30 | gpg --batch --yes -z 9 -vv --passphrase-file $KEY --output full.sec --symmetric full.sql
31 |
32 | #-------------------------------------
33 | echo --------- $(date +"%F %T")
34 | #-------------------------------------
35 |
36 | #-end-#
37 |
38 |
--------------------------------------------------------------------------------
/staging/01/wp-upgrade.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # 2019-10-24
5 | #
6 |
7 | S=sitename
8 |
9 | cd /var/www/$S
10 |
11 | echo ====== $0 $(date +"%F %T") $(pwd)
12 |
13 |
14 | WP="wp --path=htdocs --allow-root"
15 |
16 | export HTTP_HOST=localhost
17 |
18 | $WP transient delete --all
19 |
20 | $WP core update
21 | $WP core update-db
22 | $WP core verify-checksums
23 |
24 | $WP theme update --all
25 | $WP language theme update --all
26 |
27 | $WP plugin update --all
28 | $WP language plugin update --all
29 |
30 |
--------------------------------------------------------------------------------
/woo/custom-woocommerce-status.php:
--------------------------------------------------------------------------------
1 | 'Awaiting shipment',
8 | 'public' => true,
9 | 'exclude_from_search' => false,
10 | 'show_in_admin_all_list' => true,
11 | 'show_in_admin_status_list' => true,
12 | 'label_count' => _n_noop( 'Awaiting shipment (%s)', 'Awaiting shipment (%s)' )
13 | ) );
14 |
15 |
16 | register_post_status( 'wc-awaiting-ship', array(
17 | 'label' => 'Awaiting ship',
18 | 'public' => true,
19 | 'exclude_from_search' => false,
20 | 'show_in_admin_all_list' => true,
21 | 'show_in_admin_status_list' => true,
22 | 'label_count' => _n_noop( 'Awaiting ship (%s)', 'Awaiting ship (%s)' )
23 | ) );
24 | }
25 | add_action( 'init', 'register_awaiting_shipment_order_status' );
26 |
27 | // Add to list of WC Order statuses
28 | function add_awaiting_shipment_to_order_statuses( $order_statuses ) {
29 |
30 | $new_order_statuses = array();
31 |
32 | // add new order status after processing
33 | foreach ( $order_statuses as $key => $status ) {
34 |
35 | $new_order_statuses[ $key ] = $status;
36 |
37 | //add two custom status after processing status
38 | if ( 'wc-processing' === $key ) {
39 | $new_order_statuses['wc-awaiting-shipment'] = 'Awaiting shipment';
40 | $new_order_statuses['wc-awaiting-ship'] = 'Awaiting ship';
41 | }
42 | }
43 |
44 | return $new_order_statuses;
45 | }
46 |
47 | add_filter( 'wc_order_statuses', 'add_awaiting_shipment_to_order_statuses' );
48 |
49 |
50 |
51 | /
52 | function register_my_bulk_actions( $bulk_actions ) {
53 | $bulk_actions['wc-awaiting-shipment'] = __( 'Custom Bulk Action-awaiting-shipment', 'domain' );
54 | $bulk_actions['wc-awaiting-ship'] = __( 'Custom Bulk Action-awaiting-ship', 'domain' );
55 | return $bulk_actions;
56 | }
57 |
58 | add_filter( 'bulk_actions-edit-shop_order', 'register_my_bulk_actions' );
59 |
60 |
61 |
62 | function my_bulk_action_handler( $redirect_to, $action, $post_ids ) {
63 | if ( ! in_array($action, array('wc-awaiting-shipment', 'wc-awaiting-ship'))) {
64 | return $redirect_to;
65 | }
66 |
67 | foreach ( $post_ids as $post_id ) {
68 | wp_update_post( array(
69 | 'ID' => $post_id,
70 | 'post_status' => $action,
71 | ) );
72 | }
73 |
74 | $redirect_to = add_query_arg( 'bulk_draft_posts', count( $post_ids ), $redirect_to );
75 |
76 | return $redirect_to;
77 | }
78 |
79 | add_filter( 'handle_bulk_actions-edit-shop_order', 'my_bulk_action_handler', 10, 3 );
80 |
81 |
82 | function my_bulk_action_admin_notice() {
83 | if ( ! empty( $_REQUEST['bulk_draft_posts'] ) ) {
84 | $drafts_count = intval( $_REQUEST['bulk_draft_posts'] );
85 |
86 | printf(
87 | '' .
88 | _n( '%s post moved to drafts.', '%s posts moved to drafts.', $drafts_count, 'domain' )
89 | . '
',
90 | $drafts_count
91 | );
92 | }
93 | }
94 |
95 | add_action( 'admin_notices', 'my_bulk_action_admin_notice' );
96 |
97 |
--------------------------------------------------------------------------------
/woo/remove-db-update-notice.php:
--------------------------------------------------------------------------------
1 | set_notice_actioned();
11 | }
12 |
13 | add_action( 'admin_notices', 'woocommerce_set_database_update_notice_as_actioned' );
14 |
15 |
--------------------------------------------------------------------------------
/wops/kalapacs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
4 |
5 | cd /var/www/_log
6 |
7 | wget -T 3 -t 2 -S -o wget.log https://domain.tld/?s=e -O wget.html
8 |
9 | gawk '
10 |
11 | /wget.*saved/ {
12 | OK++;
13 | print $0 >> "ok.log";
14 | }
15 |
16 | END {
17 | if(1 > OK) {
18 | print strftime("%Y-%m-%d %H:%M:%S") >> "error.log";
19 | system("wo stack restart --nginx");
20 | }
21 | }
22 |
23 | ' wget.log
24 |
--------------------------------------------------------------------------------
/wops/wordpress-phpfpm-fastcache-php74-ssl.sh:
--------------------------------------------------------------------------------
1 |
2 | wo site create domain.tld --wpfc --php74 --le=on --force
3 |
4 |
5 |
--------------------------------------------------------------------------------
/wp-cli/update-all.sh:
--------------------------------------------------------------------------------
1 | # Plugin updates
2 | wp plugin update --all
3 | wp plugin update --all --skip-plugins --skip-themes
4 |
5 | # Theme updates
6 | wp theme update --all
7 | wp theme update --all --skip-plugins --skip-themes
8 |
9 | # Core updates
10 | wp core update
11 | wp core update-db
12 |
13 | # Core updates on multisite network
14 | if $( wp core is-installed --network ); then
15 | wp core update-db --network
16 | fi
17 |
18 | # Handle WooCommerce database updates if installed
19 | if $( wp plugin is-installed woocommerce ); then
20 | wp wc update
21 | fi
22 |
23 | # Handle WooCommerce database updates on multisite if installed
24 | if $( wp plugin is-installed woocommerce ) && $( wp core is-installed --network ); then
25 | for site_id in $( wp site list --field=blog_id ); do
26 | site_url=$( wp site list --field=url --blog_id=${site_id} )
27 | if $( wp plugin is-active woocommerce --url=$site_url ); then
28 | wp wc update --url=${site_url}
29 | fi
30 | done
31 | fi
32 |
33 | # Handle Elementor database updates if installed
34 | if $( wp plugin is-installed elementor ); then
35 | wp elementor update db
36 | # Handle Elementor database updates on multisite
37 | if $( wp core is-installed --network ); then
38 | wp elementor update db --network
39 | fi
40 | fi
41 |
42 | # Handle redirection database updates if installed
43 | if $( wp plugin is-installed redirection ); then
44 | wp redirection database upgrade
45 | fi
46 |
--------------------------------------------------------------------------------
/wp-config/block-external.php:
--------------------------------------------------------------------------------
1 |
2 | define( 'WP_HTTP_BLOCK_EXTERNAL', true );
3 | define( 'WP_ACCESSIBLE_HOSTS', 'api.wordpress.org,downloads.wordpress.org' );
4 |
--------------------------------------------------------------------------------
/wp-config/debug.php:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // debug log
4 | //
5 |
6 | define('WP_DEBUG', true);
7 | define('WP_DEBUG_DISPLAY', false);
8 | define('WP_DEBUG_LOG', true);
9 |
10 |
--------------------------------------------------------------------------------
/wp-config/normal.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | define( 'WP_MEMORY_LIMIT', '256M' );
4 | define( 'WP_MAX_MEMORY_LIMIT', '512M' );
5 |
6 | define( 'CONCATENATE_SCRIPTS', false );
7 | define( 'WP_POST_REVISIONS', '10' );
8 | define( 'MEDIA_TRASH', true );
9 | define( 'EMPTY_TRASH_DAYS', '15' );
10 | define( 'WP_AUTO_UPDATE_CORE', 'minor' );
11 |
12 |
--------------------------------------------------------------------------------
/wp-config/test-1.php:
--------------------------------------------------------------------------------
1 |
2 | define('WP_CACHE', true);
3 |
4 | define('WP_HTTP_BLOCK_EXTERNAL', TRUE);
5 | define('WP_ACCESSIBLE_HOSTS', 'update.wp-expert.hu,api.wordpress.org,downloads.wordpress.org');
6 |
7 | define('WP_DEBUG', true);
8 | define('WP_DEBUG_DISPLAY', false);
9 | define('WP_DEBUG_LOG', true);
10 |
11 | define('WP_MEMORY_LIMIT', '256M');
12 | define('WP_MAX_MEMORY_LIMIT', '512M');
13 |
14 | define('CONCATENATE_SCRIPTS', false);
15 | define('WP_POST_REVISIONS', '10');
16 | define('MEDIA_TRASH', true);
17 | define('EMPTY_TRASH_DAYS', '15');
18 | define('WP_AUTO_UPDATE_CORE', 'minor');
19 |
20 |
--------------------------------------------------------------------------------
/wp-config/test-big-woo-1.php:
--------------------------------------------------------------------------------
1 |
2 | define('WP_DEBUG', true);
3 | define('WP_DEBUG_DISPLAY', false);
4 | define('WP_DEBUG_LOG', true);
5 |
6 |
7 | define('WP_MEMORY_LIMIT', '256M');
8 | define('WP_MAX_MEMORY_LIMIT', '512M');
9 |
10 | define('CONCATENATE_SCRIPTS', false);
11 | define('WP_POST_REVISIONS', ' 10');
12 | define('MEDIA_TRASH', true);
13 | define('EMPTY_TRASH_DAYS', '15');
14 | define('WP_AUTO_UPDATE_CORE', 'minor');
15 |
--------------------------------------------------------------------------------
/www-scripts/dev/backup-www.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # monthly incremental backup
5 | #
6 | # v2
7 | #
8 |
9 | ID=lxc-www
10 |
11 | SRC=/var/www
12 | DIR=/BACKUP/www
13 |
14 | HOST=$(hostname)
15 |
16 | CPU=2
17 |
18 | # --------------------------------------------
19 |
20 | touch $SRC/backup.flag
21 |
22 | NOW=$(date +%Y-%m)
23 |
24 | LOG=$DIR/log/$NOW.log
25 |
26 | mkdir -p $DIR/log
27 |
28 | # --------------------------------------------
29 |
30 | echo ====== $(date +"%Y-%m-%d %H:%M:%S") >> $LOG
31 |
32 | time mksquashfs $SRC $DIR/$ID-$HOST-$NOW.sq \
33 | -comp lz4 \
34 | -Xhc \
35 | -b 1m \
36 | -processors $CPU \
37 | -root-becomes ... | tee -a $LOG
38 |
39 | echo ------ $(date +"%Y-%m-%d %H:%M:%S") >> $LOG
40 |
41 | # --------------------------------------------
42 |
43 | #-eof-#
44 |
--------------------------------------------------------------------------------
/www-scripts/dev/chown.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | chown -R www-data:www-data htdocs
4 |
5 |
--------------------------------------------------------------------------------