{"id":4301,"date":"2020-09-10T00:17:48","date_gmt":"2020-09-09T21:17:48","guid":{"rendered":"https:\/\/www.margarit.com.tr\/?p=4301"},"modified":"2020-09-10T00:46:58","modified_gmt":"2020-09-09T21:46:58","slug":"sik-karsilasilan-wordpress-hatalari-ve-cozumleri","status":"publish","type":"post","link":"https:\/\/www.margarit.com.tr\/en\/sik-karsilasilan-wordpress-hatalari-ve-cozumleri\/","title":{"rendered":"Common WordPress errors and solutions"},"content":{"rendered":"<p>No matter what theme you use, Woocommerce or not, WordPress plugins can present crazy problems when WordPress themes all go together. Considering that the WordPress CMS system, which is an open source infrastructure system, acts with millions of users, a worldwide delegation of manufacturers \/ developers and thousands of alternative applications; It doesn&#039;t seem likely that it will cause any problems.<\/p>\n\n\n\n<p>In this article, we will try to cover a few of the standard and often annoying WordPress error notifications and WordPress error solutions that you may encounter as a WordPress user. We hope that the short-term solution plans will be partners in the solutions of the problems mentioned here, and you can accompany us with your comments.<\/p>\n\n\n\n<h3>WordPress You are not authorized to attach files to this post error solution<\/h3>\n\n\n\n<p>Very interestingly, it is translated as \u201cYou don&#039;t have permission to attach files to this post.\u201d In other words, we are sharing code for the problem of &quot;You are not authorized to attach files to this article&quot; problem to archive and remember later.<\/p>\n\n\n\n<p>To be able to intervene in the WordPress file operation authorization error <strong>wp-admin\/includes\/ ajax-action.php<\/strong> Below are the lines to be deleted from the file. <\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>if ( isset( $_REQUEST[&#039;post_id&#039;] ) ) { $post_id = $_REQUEST[&#039;post_id&#039;]; if ( ! current_user_can( &#039;edit_post&#039;, $post_id ) ) { echo wp_json_encode( array( &#039;success&#039; =&gt; false, &#039;data&#039;, $post_id ) ) { echo wp_json_encode( array( &#039;success&#039; =&gt; false, &#039;data&#039; =&gt; You don&amp;391; to attach files to this post.&quot; ), &#039;filename&#039; =&gt; $_FILES[&#039;async-upload&#039;][&#039;name&#039;], ) ) ); wp_die(); } }<\/code><\/pre><\/div>\n\n\n\n<h3>WordPress \u201cSorry, this file type is not allowed for security reasons.\u201d error and solution<\/h3>\n\n\n\n<p>If you have been dealing with wordpress for a while and you are starting to push the limits, it is one of the mistakes you will definitely encounter.<\/p>\n\n\n\n<p>To solve the problem, we will request permission by adding to your theme&#039;s functions.php file without interfering with the wordpress core.<\/p>\n\n\n\n<p>I give the example for mp3 format, the rest is up to you;\u00a0<a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/get_allowed_mime_types\">from this list<\/a>\u00a0You can have a look.<\/p>\n\n\n\n<p>Code to add in WordPress file type error solution:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>add_filter(&#039;upload_mimes&#039;,&#039;external_mimes&#039;); function external_mimes($mimes){ return array_merge($mimes,array ( &#039;mp3&#039; =&gt; &#039;audio\/mpeg&#039; )); }<\/code><\/pre><\/div>\n\n\n\n<p>If you are asking if there is more, you can follow the long list below.<\/p>\n\n\n\n<p>Take a look at the codes for mime type definitions that can be used as an alternative in WordPress file type error resolution.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plane\"><code>array( \/\/ Image formats &#039;jpg|jpeg|jpe&#039; =&gt; &#039;image\/jpeg&#039;, &#039;gif&#039; =&gt; &#039;image\/gif&#039;, &amp;#P339;139; ;bmp&#039; =&gt; &#039;image\/bmp&#039;, &#039;tif|tiff&#039; =&gt; &#039;image\/tiff&#039;, &#039;ico&#039; =&gt; &#039; asx&#039; =&gt; &#039;video\/x-ms-asf&#039;, &#039;wmv&#039; =&gt; &#039;video\/x-ms-wmv&#039;, &#039;wmx&#039;wmv&#039; ;wm&#039; =&gt; &#039;video\/x-ms-wm&#039;, &#039;avi&#039; =&gt; &#039;video\/avi&#039;, &#039;divx&#039; =&gt;TP&#039; video\/x-flv&#039;, &#039;mov|qt&#039; =&gt; &#039;video\/quicktime&#039;, &#039;mpeg|mpg|mpe&#039; =&gt; &#039;video\/mpeg&gt;4T4T39; \/mp4&#039;, &#039;ogv&#039; =&gt; &amp;1 TP4T39;video\/ogg&#039;, &#039;webm&#039; =&gt; &#039;video\/webm&#039;, &#039;mkv&#039; =&gt; &#039;video\/x-matroska&#039;, \/\/ Text formats &#039;txt|asc|c|cc|h&#039; =&gt; &#039;text\/plain&#039;, &#039;csv&#039; =&gt; &#039;text\/csv&#039;, &#039;tsv&#039; =&gt; &#039;text\/tab-separated-values&#039;, &#039;ics&#039; =&gt; &#039;text\/calendar&#039;, &#039;rtx&#039; =&gt; &#039;text\/richtext&#039;, &#039;css&#039; =&gt; &#039;text\/css&#039;, &#039;htm|html&#039; =&gt; &#039;text\/html&#039;, \/\/ Audio formats &#039;mp3|m4a|m4b&#039; =&gt; &#039;audio\/mpeg&#039;, &#039;ra|ram&#039; =&gt; &#039;audio\/x-realaudio&#039;, &#039;wav&#039; =&gt; &#039;audio\/wav&#039;, &#039;ogg|oga&#039; =&gt; &#039;audio\/ogg&#039;, &#039;mid|midi&#039; =&gt; &#039;audio\/midi&#039;, &#039;wma&#039; =&gt; &#039;audio\/x-ms-wma&#039;, &#039;wax&#039; =&gt; &#039;audio\/x-ms-wax&#039;, &#039;mka&#039; =&gt; &#039;audio\/x-matroska&#039;, \/\/ Misc application formats &#039;rtf&#039; =&gt; &#039;application\/rtf&#039;, &#039;js&#039; =&gt; &#039;application\/j\u0430vascript&#039;, &#039;pdf&#039; =&gt; &#039;application\/pdf&#039;, &#039;swf&#039; =&gt; &#039;application\/x-shockwave-flash&#039;, &#039;class&#039; =&gt; &#039;application\/java&#039;, &#039;tar&#039; =&gt; &#039;application\/x-tar&#039;, &#039;zip&#039; =&gt; &#039;application\/zip&#039;, &#039;gz|gzip&#039; =&gt; &#039;application\/x-gzip&#039;, &#039;rar&#039; =&gt; &#039;application\/rar&#039;, &#039;7z&#039; =&gt; &#039;application\/x-7z-compressed&#039;, &#039;exe&#039; =&gt; &#039;application\/x-msdownload&#039;, \/\/ MS Office formats &#039;doc&#039; =&gt; &#039;application\/msword&#039;, &#039;pot|pps|ppt&#039; =&gt; &#039;application\/vnd.ms-powerpoint&#039;, &#039;wri&#039; =&gt; &#039;application\/vnd.ms-write&#039;, &#039;xla|xls|xlt|xlw&#039; =&gt; &#039;application\/vnd.ms-excel&#039;, &#039;mdb&#039; =&gt; &#039;application\/vnd.ms-access&#039;, &#039;mpp&#039; =&gt; &#039;application\/vnd.ms-project&#039;, &#039;docx&#039; =&gt; &#039;application\/vnd.openxmlformats-officedocument.wordprocessingml.document&#039;, &#039;docm&#039; =&gt; &#039;application\/vnd.ms-word.document.macroEnabled.12&#039;, &#039;dotx&#039; =&gt; &#039;application\/vnd.openxmlformats-officedocument.wordprocessingml.template&#039;, &#039;dotm&#039; =&gt; &#039;application\/vnd.ms-word.template.macroEnabled.12&#039;, &#039;xlsx&#039; =&gt; &#039;application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet&#039;, &#039;xlsm&#039; =&gt; &#039;application\/vnd.ms-excel.sheet.macroEnabled.12&#039;, &#039;xlsb&#039; =&gt; &#039;application\/vnd.ms-excel.sheet.binary.macroEnabled.12&#039;, &#039;xltx&#039; =&gt; &#039;application\/vnd.openxmlformats-officedocument.spreadsheetml.template&#039;, &#039;xltm&#039; =&gt; &#039;application\/vnd.ms-excel.template.macroEnabled.12&#039;, &#039;xlam&#039; =&gt; &#039;application\/vnd.ms-excel.addin.macroEnabled.12&#039;, &#039;pptx&#039; =&gt; &#039;application\/vnd.openxmlformats-officedocument.presentationml.presentation&#039;, &#039;pptm&#039; =&gt; &#039;application\/vnd.ms-powerpoint.presentation.macroEnabled.12&#039;, &#039;ppsx&#039; =&gt; &#039;application\/vnd.openxmlformats-officedocument.presentationml.slideshow&#039;, &#039;ppsm&#039; =&gt; &#039;application\/vnd.ms-powerpoint.slideshow.macroEnabled.12&#039;, &#039;potx&#039; =&gt; &#039;application\/vnd.openxmlformats-officedocument.presentationml.template&#039;, &#039;potm&#039; =&gt; &#039;application\/vnd.ms-powerpoint.template.macroEnabled.12&#039;, &#039;ppam&#039; =&gt; &#039;application\/vnd.ms-powerpoint.addin.macroEnabled.12&#039;, &#039;sldx&#039; =&gt; &#039;application\/vnd.openxmlformats-officedocument.presentationml.slide&#039;, &#039;sldm&#039; =&gt; &#039;application\/vnd.ms-powerpoint.slide.macroEnabled.12&#039;, &#039;onetoc|onetoc2|onetmp|onepkg&#039; =&gt; &#039;application\/onenote&#039;, \/\/ OpenOffice formats &#039;odt&#039; =&gt; &#039;application\/vnd.oasis.opendocument.text&#039;, &#039;odp&#039; =&gt; &#039;application\/vnd.oasis.opendocument.presentation&#039;, &#039;ods&#039; =&gt; &#039;application\/vnd.oasis.opendocument.spreadsheet&#039;, &#039;odg&#039; =&gt; &#039;application\/vnd.oasis.opendocument.graphics&#039;, &#039;odc&#039; =&gt; &#039;application\/vnd.oasis.opendocument.chart&#039;, &#039;odb&#039; =&gt; &#039;application\/vnd.oasis.opendocument.database&#039;, &#039;odf&#039; =&gt; &#039;application\/vnd.oasis.opendocument.formula&#039;, \/\/ WordPerfect formats &#039;wp|wpd&#039; =&gt; &#039;application\/wordperfect&#039;, \/\/ iWork formats &#039;key&#039; =&gt; &#039;application\/vnd.apple.keynote&#039;, &#039;numbers&#039; =&gt; &#039;application\/vnd.apple.numbers&#039;, &#039;pages&#039; =&gt; &#039;application\/vnd.apple.pages&#039;, )<\/code><\/pre><\/div>\n\n\n\n<h3>WordPress admin bar disappeared<\/h3>\n\n\n\n<p>The problem is unbelievably simple and emerges in annoying moments without you noticing.<\/p>\n\n\n\n<p>You see, there is a space above with the admin bar, you are logged in, but instead of the bar itself, a space appears.<\/p>\n\n\n\n<p>In this case, in footer.php in your theme files You should check if the line exists.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>&lt;?php wp_footer(); ?&gt;<\/code><\/pre><\/div>\n\n\n\n<p>This line is in your theme&amp;#039;s footer.php &lt;\/body&gt; It can be solved by placing it before the tag. Example footer.php ending should be:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-html\" data-lang=\"HTML\"><code>&lt;\/div&gt;&lt;!-- \/page --&gt;\n&lt;?php wp_footer(); ?&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre><\/div>\n\n\n\n<h3>How to bulk delete all media files and images on WordPress site with SQL?<\/h3>\n\n\n\n<p>You have thousands of derived files and you are lazy to clean wordpress installation.<\/p>\n\n\n\n<p>To delete all media files with a single SQL code, simply use the code below.<\/p>\n\n\n\n<p>I hope you can use it as a SQL query from the phpmyadmin panel.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code> \nDELETE FROM wp_postmeta WHERE post_id IN ( SELECT id FROM wp_posts WHERE post_type = &#039;attachment&#039; ) ; # Second: DELETE FROM wp_posts WHERE post_type = &#039;attachment&#039;<\/code><\/pre><\/div>\n\n\n\n<p>You won&#039;t forget to edit the wp_posts and wp_postmeta keys according to the prefix on your own site, right? \ud83d\ude42<\/p>\n\n\n\n<h3>Remove sitelink from WordPress comments<\/h3>\n\n\n\n<p>I am adding it to keep it in the archive in a simple and short way, if it helps us, we will be happy.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>function crunchify_disable_comment_url($fields) { unset($fields[&#039;url&#039;]); return $fields; } add_filter(&#039;comment_form_default_fields&#039;,&#039;crunchify_disable_comment_url&#039;);<\/code><\/pre><\/div>\n\n\n\n<p><strong>functions.php <\/strong>Just add the following code to the file.<br><strong>or comments.php<\/strong>\u00a0Delete the following part from the file:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>&amp;#39;&lt;p class=&quot;comment-form-url&quot;&gt;&lt;label for=&quot;url&quot;&gt;&amp;#039; . __vce( &amp;#039;comment_website&amp;#039; ) . &amp;#039;&lt;\/label&gt;&amp;#39; .\n&amp;#39;&lt;input id=&quot;url&quot; name=&quot;url&quot; type=&quot;text&quot; value=&quot;&amp;#39; . esc_attr( $commenter[&amp;#39;comment_author_url&amp;#39;] ) .&amp;#39;&quot; size=&quot;30&quot; \/&gt;&lt;\/p&gt;&amp;#39;<\/code><\/pre><\/div>\n\n\n\n<p>Also the code below for a neat view<strong>\u00a0stlye.css\u00a0<\/strong>add to file.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-css\" data-lang=\"CSS\"><code>.comment-form-author, .comment-form-email { width:100%; }<\/code><\/pre><\/div>\n\n\n\n<h3>WordPress slowness problem and slower with Woocommerce<\/h3>\n\n\n\n<p>As a Woocommerce user, if you have thousands of product ranges, unfortunately, you install many plugins for your cashier system and try to find a solution with Cache systems.<\/p>\n\n\n\n<p>However, since Woocommerce is a system that appeals to the whole world, it is a system that compulsorily runs many unnecessary functions simultaneously. To alleviate this load, you can lighten the distribution of functions that you deem unnecessary, so that the features you do not use are not called by the system and save you speed \/ time.<\/p>\n\n\n\n<p>The code I have given below <strong>into your theme&#039;s functions.php file<\/strong> Just add it, then you can delete the lines you want or you can add others. I&#039;m sure you will gain a noticeable speed this way!<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>add_action( &#039;wp_enqueue_scripts&#039;, &#039;child_manage_woocommerce_styles&#039;, 99 ); function child_manage_woocommerce_styles() { \/\/remove generator meta tag remove_action( &#039;wp_head&#039;, array( $GLOBALS[&#039;woocommerce&#039;], &#039;generator&#039; ) ); \/\/first check that woo exists to prevent fatal errors if ( function_exists( &#039;is_woocommerce&#039; ) ) { \/\/dequeue scripts and styles if ( ! is_woocommerce() &amp;&amp; ! is_cart() &amp;&amp; ! is_checkout() ) { wp_dequeue_style( &#039; woocommerce_frontend_styles&#039; ); wp_dequeue_style( &#039;woocommerce_fancybox_styles&#039; ); wp_dequeue_style( &#039;woocommerce_chosen_styles&#039; ); wp_dequeue_style( &#039;woocommerce_prettyPhoto_css&#039; ); wp_dequeue_script( &#039;wc_price_slider&#039; ); wp_dequeue_script( &#039;wc-single-product&#039; ); wp_dequeue_script( &#039;wc-add-to-cart&#039; ); wp_dequeue_script( &#039;wc-cart-fragments&#039; ); wp_dequeue_script( &#039;wc-checkout&#039; ); wp_dequeue_script( &#039;wc-add-to-cart-variation&#039; ); wp_dequeue_script( &#039;wc-single-product&#039; ); wp_dequeue_script( &#039;wc-cart&#039; ); wp_dequeue_script( &#039;wc-chosen&#039; ); wp_dequeue_script( &#039;woocommerce&#039; ); wp_dequeue_script( &#039;prettyPhoto&#039; ); wp_dequeue_script( &#039;prettyPhoto-init&#039; ); wp_dequeue_script( &#039;jquery-blockui&#039; ); wp_dequeue_script( &#039;jquery-placeholder&#039; ); wp_dequeue_script( &#039;fancybox&#039; ); wp_dequeue_script( &#039;jqueryui&#039; ); } } }<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Considering that the Wordpress CMS system moves with millions of users; It doesn&#039;t seem likely that it will cause any problems.<\/p>","protected":false},"author":1,"featured_media":4284,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[226,223,227,220,231,234,221,233,230,235,219,228,229,224,232,225],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/posts\/4301"}],"collection":[{"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/comments?post=4301"}],"version-history":[{"count":1,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/posts\/4301\/revisions"}],"predecessor-version":[{"id":4302,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/posts\/4301\/revisions\/4302"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/media\/4284"}],"wp:attachment":[{"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/media?parent=4301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/categories?post=4301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.margarit.com.tr\/en\/wp-json\/wp\/v2\/tags?post=4301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}