WordPress upload file - wordpress

I would like to upload a file like as (.apk) but I can't. I receive this message.
Sorry, this file type is not allowed for security reasons.
I show solutions as to settings on multisite, but I don't have this choice on my version. In which way I could enable the settings of multisite?
Is there any way to upload files like apk,( may a plugin)?
Thank you in advance!

Open your functions.php file and add the following code inside it.
add_filter('upload_mimes', 'allow_custom_mimes');
function allow_custom_mimes ( $existing_mimes = array() ) {
// with mime type ‘application/vnd.android.package-archive
$existing_mimes['apk'] = 'application/vnd.android.package-archive';
return $existing_mimes;
}
Restart your server after adding code and check.

Related

Uploading .dta and do files on wordpress

I am currently building a website for sharing statistical files. I am using wordpress CMS to build it. However, when I try to upload files with extension .dta and do files, it raises this error:
cr-ethdat1997-version3.do: Sorry, this file type is not permitted for security reasons.
How can I resolve it?
If you don't want WordPress to check what file types you are uploading, you can add a constant in the wp-config.php file:
define( 'ALLOW_UNFILTERED_UPLOADS', true );
Otherwise, if you want file type checking, you could add certain mime types with the following filter:
function my_custom_mime_types( $mimes ) {
// New allowed mime types.
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
$mimes['doc'] = 'application/msword';
return $mimes;
}
add_filter( 'upload_mimes', 'my_custom_mime_types' );
You would need to find the MIME types for the files you'd want to upload (.do, .dta)
Take a look at the Codex for more details: https://developer.wordpress.org/reference/hooks/upload_mimes/

Uploading .kml files to WordPress

I'm trying to upload .kml files to WordPress. I had this working at one point but the latest WordPress update seems to have broken it.
I'm using this function
function my_myme_types($mime_types){
$mime_types['kml'] = 'application/vnd.google-earth.kml+xml'; //Adding kml extension
$mime_types['kmz'] = 'application/vnd.google-earth.kmz'; //Adding kmz files
return $mime_types;
}
add_filter('upload_mimes', 'my_myme_types', 1, 1);
I get this error when uploading
"Sorry, this file type is not permitted for security reasons."
For KML/KMZ files to be properly supported, you'll have to use text/xml and application/zip instead, because WordPress compares the declared MIME type to the 'real' detected MIME type (see function wp_check_filetype_and_ext in wp-includes/functions.php for more details)
function add_upload_mimes($mimes) {
$mimes['kml'] = 'text/xml';
$mimes['kmz'] = 'application/zip';
return $mimes;
}
add_filter('upload_mimes', 'add_upload_mimes');
Update (2019-02-28) : kml is detected as text/xml and not application/xml, changing the code accordingly should resolve the issue described in the comments below.
This may be related as of after the latest wordpress update:
Trying to upload xml file and getting the same error message, updating upload_mimes WordPress filter hook doesn't work as well as using some file uploading or mime type managing plugins which essentially using the same filter hook.
Solution: update wp-config.php and add in the following line
define( 'ALLOW_UNFILTERED_UPLOADS', true );
and then remove this line after uploading the files to avoid potential security risk

Enabling hook form alter module - not showing up in modules

Good Day,
I am doing a hook_form_alter and followed a tutorial where you create a directory in your /sites/all/modules directory and place the module.info and mymodule.module files within. I've called that directory mymodule so the path will be /sites/all/modules/mymodule.
The problem I'm having is trying to enable the module. It does not show up in the list of Modules when I check. It's clearly in my directory.
My module (my_module.module) looks like this and is going to be used to modify the form where you add the product (basically taking out the SKU, list price and commission):
<?php
// $Id$
/**
* #file
* Module to hold my customizations to Ubercart
*/
/**
* Implementation of hook_form_alter()
*/
function my_module_form_alter($form_id, &$form) {
if ($form_id == 'product_node_form') {
$form['base']['model']['#required'] = FALSE;
$form['base']['prices']['list_price']['#required'] = FALSE;
$form['base']['prices']['cost']['#required'] = FALSE;
$form['base']['prices']['sell_price']['#required'] = FALSE;
$form['base']['prices']['shippable']['#required'] = FALSE;
}
}
And the info file, my_module.info, looks like this:
; $Id$
name = My module
description = My customizations to Ubercart
package = Custom
core = 7.x
Why would it not show up in the modules list and how do I make Drupal see the module so I can enable it?
I don't have a category called Custom and nothing is showing up.
So far, i've gone into my php.ini file and put in safe_mode=off to see if that would help (because someone said this sometimes causes Drupal to ignore new modules for some reason) but that didn't help.
I created both files on the server so I don't think there would be any issues with something like linefeeds (I use GoDaddy's FTP File Manager and it comes with an editor.)
What could the problem be because I'm stumped?
Thanks for looking.
Make sure to name the .info and .module files with the same name.
E.g. mymodule.info and mymodule.module.
Note that, the name should be alpha-numeric (underscore is allowed) and starts with a letter.
In your hook implementation, replace the word hook with your module's name
function mymodule_form_alter($form, &$form_state, $form_id)
{
// code goes here...
}
I discovered something that works. After reading about people having issues with linefeeds and not knowing if this was creating the problem, I decided to try something.
I went to a module directory and found a .info file. In my case, I went to a directory that had Commerce in it and copied the Commerce.info file to my custom module's directory.
Then, what I did was take out the stuff that Drupal added after it installed the Commerce module (you can do the same for whatever .info file you copy from) and modified the information at the start, removing any dependency lines or anything that doesn't matter. In other words, make it like the .info file you are trying to use but DON'T COPY from the .info you've been trying to enable!
Save it this file (in my case, it's still commerce.info.)
Now delete the .info file you were trying to enable originally.
Rename the new .info file to the name you wanted (commerce.info => mymodule.info.)
Go to your Modules page and refresh it.
Voila...there it is. Enable and save configuration.

How to remove Query String "?" (question mark) from URL (Using Wordpress)

I was using wordpress 3.3 to power my website. I tested it with Page Speed and it gave me error "remove query string from URL).... The query string is a question mark which appears in the start of query paramter of the url.....
http://gizmocube.com/images/logo.png .... is outputted as ...
http://gizmocube.com/images/logo.png?9d7bd4
how do i get rid of this question mark.... any .htacess stuff... any help would be appreciated....
Do you have W3 Total Cache Installed ? (Wordpress Plugin) , If you do
Go to the Browser Cache Tab
Untick
Prevent caching of objects after settings change
Whenever settings are changed, a new query string will be generated and appended to objects allowing the new policy to be applied.
Clear the Cache then It's gone :)
Hope this helps
--
Source
Myself (Having the same issue myself )
Go to the Browser Cache Tab > untick "Prevent caching of objects after settings change".
This will slove the issue.
Change your Permalink settings from the default with question marks to a format you prefer under /wp-admin/options-permalink.php
Default: http://www.example.com/?p=123
Day and name: http://www.example.com/2012/03/02/sample-post/
Month and name: http://www.example.com/2012/03/sample-post/
Numeric: http://www.example.com/archives/123
Post name: http://www.example.com/sample-post/
Custom Structure: /%year%/%monthnum%/%postname%/
Add this code to your functions.php file, it works for my sites.
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 );

Grabbing Get option function from php file in plugin folders

Really need some help i am making a plugin within the main plugin i have the code.
// Some Defaults
$bucket = 'music';
// Put our defaults in the "wp-options" table
add_option("isd-bucket", $bucket);
so thats great for me i no it adds to the database music.
the problem i am have is i need to pull that out off the database into another php file in my plugin folder.
in my playlist.php i have.
echo get_option("isd-bucket");
problem is when running this file i get.
Call to undefined function get_option() in
I understand this probably means i need to require other files so it intergrates with wordpress i have tried many options but cant get it to work plese help.
Thanks
Be sure to remove the extra white space (blank line) between the lines of code.
// Some Defaults
$bucket = 'music';
// Put our defaults in the "wp-options" table
add_option( "isd-bucket" , $bucket );

Resources