本文整理汇总了PHP中wp_is_writable函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_is_writable函数的具体用法?PHP wp_is_writable怎么用?PHP wp_is_writable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_is_writable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mc_write_styles
function mc_write_styles($stylefile, $my_calendar_style)
{
if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT == true) {
return false;
}
$standard = dirname(__FILE__) . '/styles/';
$files = my_csslist($standard);
foreach ($files as $file) {
$filepath = mc_get_style_path($file);
$path = pathinfo($filepath);
if ($path['extension'] == 'css') {
$styles_whitelist[] = $filepath;
}
}
if (in_array($stylefile, $styles_whitelist)) {
if (function_exists('wp_is_writable')) {
$is_writable = wp_is_writable($stylefile);
} else {
$is_writable = is_writeable($stylefile);
}
if ($is_writable) {
$f = fopen($stylefile, 'w+');
fwrite($f, $my_calendar_style);
// number of bytes to write, max.
fclose($f);
return true;
} else {
return false;
}
}
return false;
}
示例2: edd_create_protection_files
/**
* Creates blank index.php and .htaccess files
*
* This function runs approximately once per month in order to ensure all folders
* have their necessary protection files
*
* @since 1.1.5
*
* @param bool $force
* @param bool $method
*/
function edd_create_protection_files($force = false, $method = false)
{
if (false === get_transient('edd_check_protection_files') || $force) {
$upload_path = edd_get_upload_dir();
// Make sure the /edd folder is created
wp_mkdir_p($upload_path);
// Top level .htaccess file
$rules = edd_get_htaccess_rules($method);
if (edd_htaccess_exists()) {
$contents = @file_get_contents($upload_path . '/.htaccess');
if ($contents !== $rules || !$contents) {
// Update the .htaccess rules if they don't match
@file_put_contents($upload_path . '/.htaccess', $rules);
}
} elseif (wp_is_writable($upload_path)) {
// Create the file if it doesn't exist
@file_put_contents($upload_path . '/.htaccess', $rules);
}
// Top level blank index.php
if (!file_exists($upload_path . '/index.php') && wp_is_writable($upload_path)) {
@file_put_contents($upload_path . '/index.php', '<?php' . PHP_EOL . '// Silence is golden.');
}
// Now place index.php files in all sub folders
$folders = edd_scan_folders($upload_path);
foreach ($folders as $folder) {
// Create index.php, if it doesn't exist
if (!file_exists($folder . 'index.php') && wp_is_writable($folder)) {
@file_put_contents($folder . 'index.php', '<?php' . PHP_EOL . '// Silence is golden.');
}
}
// Check for the files once per day
set_transient('edd_check_protection_files', true, 3600 * 24);
}
}
示例3: update
public function update()
{
if (!$this->is_build_with_elementor()) {
return;
}
$this->parse_elements_css();
$meta = ['version' => ELEMENTOR_VERSION, 'time' => time(), 'fonts' => array_unique($this->fonts)];
if (empty($this->css)) {
$this->delete();
$meta['status'] = self::CSS_STATUS_EMPTY;
$meta['css'] = '';
} else {
$file_created = false;
if (wp_is_writable(dirname($this->path))) {
$file_created = file_put_contents($this->path, $this->css);
}
if ($file_created) {
$meta['status'] = self::CSS_STATUS_FILE;
} else {
$meta['status'] = self::CSS_STATUS_INLINE;
$meta['css'] = $this->css;
}
}
$this->update_meta($meta);
}
示例4: wpum_admin_messages
/**
* Admin Messages
*
* @since 1.0
* @global $wpum_options Array of all the WPUM Options
* @return void
*/
function wpum_admin_messages()
{
global $wpum_options;
$screen = get_current_screen();
if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true && !wpum_get_option('custom_passwords') && wpum_get_option('password_strength')) {
add_settings_error('wpum-notices', 'custom-passwords-disabled', __('You have enabled the "Minimum Password Strength" option, the "Users custom passwords" is currently disabled and must be enabled for custom passwords to work.', 'wpum'), 'error');
}
if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true && !wpum_get_option('custom_passwords') && wpum_get_option('login_after_registration')) {
add_settings_error('wpum-notices', 'custom-passwords-disabled', __('Error: the option "Login after registration" can only work when the option "Users custom passwords" is enabled too.', 'wpum'), 'error');
}
if (isset($_GET['emails-updated']) && $_GET['emails-updated'] == true) {
add_settings_error('wpum-notices', 'emails-updated', __('Email successfully updated.', 'wpum'), 'updated');
}
// Display Errors in plugin settings page
if ($screen->base == 'users_page_wpum-settings') {
// Display error if no core page is setup
if (!wpum_get_option('login_page') || !wpum_get_option('password_recovery_page') || !wpum_get_option('registration_page') || !wpum_get_option('account_page') || !wpum_get_option('profile_page')) {
add_settings_error('wpum-notices', 'page-missing', __('One or more WPUM pages are not configured.', 'wpum') . ' ' . sprintf(__('<a href="%s" class="button-primary">Click here to setup your pages</a>', 'wpum'), admin_url('users.php?page=wpum-settings&tab=general&wpum_action=install_pages')), 'error');
}
// Display error if wrong permalinks
if (get_option('permalink_structure') == '') {
add_settings_error('wpum-notices', 'permalink-wrong', sprintf(__('You must <a href="%s">change your permalinks</a> to anything else other than "default" for profiles to work.', 'wpum'), admin_url('options-permalink.php')), 'error');
}
if (isset($_GET['setup_done']) && $_GET['setup_done'] == 'true') {
add_settings_error('wpum-notices', 'pages-updated', __('Pages setup completed.', 'wpum'), 'updated');
}
if (isset($_GET['message']) && $_GET['message'] == 'fields_fixed') {
add_settings_error('wpum-notices', 'fields_fixed', __('Fields successfully fixed.', 'wpum'), 'updated');
}
}
// Verify if upload folder is writable
if (isset($_GET['wpum_action']) && $_GET['wpum_action'] == 'check_folder_permission') {
$upload_dir = wp_upload_dir();
if (!wp_is_writable($upload_dir['path'])) {
add_settings_error('wpum-notices', 'permission-error', sprintf(__('Your uploads folder in "%s" is not writable. <br/>Avatar uploads will not work, please adjust folder permission.<br/><br/> <a href="%s" class="button" target="_blank">Read More</a>', 'wpum'), $upload_dir['basedir'], 'http://www.wpbeginner.com/wp-tutorials/how-to-fix-image-upload-issue-in-wordpress/'), 'error');
} else {
add_settings_error('wpum-notices', 'permission-success', sprintf(__('No issues detected.', 'wpum'), admin_url('users.php?page=wpum-settings&tab=profile')), 'updated notice is-dismissible');
}
}
// messages for the groups and fields pages
if ($screen->base == 'users_page_wpum-profile-fields') {
if (isset($_GET['message']) && $_GET['message'] == 'group_success') {
add_settings_error('wpum-notices', 'group-updated', __('Field group successfully updated.', 'wpum'), 'updated');
}
if (isset($_GET['message']) && $_GET['message'] == 'group_delete_success') {
add_settings_error('wpum-notices', 'group-deleted', __('Field group successfully deleted.', 'wpum'), 'updated');
}
if (isset($_GET['message']) && $_GET['message'] == 'field_saved') {
add_settings_error('wpum-notices', 'field-saved', __('Field successfully updated.', 'wpum'), 'updated');
}
}
// messages for tools page
if ($screen->base == 'users_page_wpum-tools') {
if (isset($_GET['message']) && $_GET['message'] == 'settings_imported') {
add_settings_error('wpum-notices', 'settings-imported', __('Settings successfully imported.', 'wpum'), 'updated');
}
}
settings_errors('wpum-notices');
}
示例5: testFallbackPath
/**
* If the default path is unwritable then it should fallback to the fallback path
*/
public function testFallbackPath()
{
$this->assertEquals($this->path->get_default_path(), $this->path->get_path());
if (wp_is_writable($this->path->get_default_path())) {
$this->markTestSkipped('The default path was still writable');
}
$this->path->calculate_path();
$this->assertEquals($this->path->get_path(), $this->path->get_fallback_path());
$this->assertFileExists($this->path->get_fallback_path());
}
示例6: delete_report
private function delete_report($filename)
{
if (!empty($filename) && !is_string($filename)) {
return new WP_Error('invalid-argument', 'The delete-report function takes a string representing an individual report.');
}
$upload_path = Ithemes_Sync_Functions::get_upload_reports_dir();
if (!empty($upload_path) && wp_is_writable($upload_path)) {
@unlink($upload_path . '/' . $filename);
return true;
}
return false;
}
示例7: can_fix
public function can_fix()
{
if (GRAV_TESTS::is_editable()) {
$path = $this->get_wp_config_path();
if ($path && wp_is_writable($path)) {
if ($contents = file_get_contents($path)) {
$contents = GRAV_TESTS::remove_comments($contents);
if (preg_match('/define[^;]*WP_DEBUG.*(true|TRUE)[^;]*/s', $contents, $matches)) {
return true;
}
}
}
}
return false;
}
示例8: themeton_less_mkdir
function themeton_less_mkdir()
{
$upload_dir = wp_upload_dir();
if (wp_is_writable($upload_dir['basedir'])) {
$dir = 'themeton';
$path = trailingslashit($upload_dir['basedir']) . $dir;
if (!@is_dir($path)) {
if (wp_mkdir_p($path)) {
return $path;
}
} else {
return $path;
}
}
return false;
}
示例9: mc_write_styles
function mc_write_styles($stylefile, $my_calendar_style)
{
if (function_exists('wp_is_writable')) {
$is_writable = wp_is_writable($stylefile);
} else {
$is_writable = is_writeable($stylefile);
}
if ($is_writable) {
$f = fopen($stylefile, 'w+');
fwrite($f, $my_calendar_style);
// number of bytes to write, max.
fclose($f);
return true;
} else {
return false;
}
}
示例10: wpcf7_cleanup_upload_files
function wpcf7_cleanup_upload_files()
{
$dir = trailingslashit(wpcf7_upload_tmp_dir());
if (!is_dir($dir)) {
return false;
}
if (!is_readable($dir)) {
return false;
}
if (!wp_is_writable($dir)) {
return false;
}
if ($handle = @opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file == "." || $file == ".." || $file == ".htaccess") {
continue;
}
$stat = stat($dir . $file);
if ($stat['mtime'] + 60 < time()) {
// 60 secs
@unlink($dir . $file);
}
}
closedir($handle);
}
}
示例11: wpcf7_cleanup_captcha_files
function wpcf7_cleanup_captcha_files()
{
if (!($captcha = wpcf7_init_captcha())) {
return false;
}
if (is_callable(array($captcha, 'cleanup'))) {
return $captcha->cleanup();
}
$dir = trailingslashit(wpcf7_captcha_tmp_dir());
if (!is_dir($dir) || !is_readable($dir) || !wp_is_writable($dir)) {
return false;
}
if ($handle = @opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (!preg_match('/^[0-9]+\\.(php|txt|png|gif|jpeg)$/', $file)) {
continue;
}
$stat = @stat($dir . $file);
if ($stat['mtime'] + 3600 < time()) {
// 3600 secs == 1 hour
@unlink($dir . $file);
}
}
closedir($handle);
}
}
示例12: wpcf7_cleanup_upload_files
function wpcf7_cleanup_upload_files()
{
if (is_admin() || 'GET' != $_SERVER['REQUEST_METHOD'] || is_robots() || is_feed() || is_trackback()) {
return;
}
$dir = trailingslashit(wpcf7_upload_tmp_dir());
if (!is_dir($dir) || !is_readable($dir) || !wp_is_writable($dir)) {
return;
}
if ($handle = @opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file == "." || $file == ".." || $file == ".htaccess") {
continue;
}
$mtime = @filemtime($dir . $file);
if ($mtime && time() < $mtime + 60) {
// less than 60 secs old
continue;
}
wpcf7_rmdir_p(path_join($dir, $file));
}
closedir($handle);
}
}
示例13: wpstg_create_clonedetails_files
/**
* Create json cloning_details.json after activation of the plugin
*
* @return bool
*/
function wpstg_create_clonedetails_files()
{
$path = wpstg_get_upload_dir();
if (wp_is_writable($path)) {
$file = 'clone_details.json';
file_put_contents($path . '/' . $file, null);
} else {
WPSTG()->logger->info($path . '/' . $file . ' is not writeable! ');
}
}
示例14: rs_wpss_log_reset
function rs_wpss_log_reset($admin_ips = NULL, $get_fws = FALSE, $clr_hta = FALSE, $mk_log = FALSE)
{
/***
* $ip - Optional
* $get_fws - File writeable status - returns bool
* $clr_hta - Reset .htaccess only, don't reset log
* $mk_log - Make log log file if none exists
***/
$admin_ips = !empty($admin_ips) && is_array($admin_ips) ? $admin_ips : get_option('spamshield_admins');
$admin_ips = rs_wpss_remove_expired_admins($admin_ips);
if (!empty($admin_ips) && is_array($admin_ips)) {
$admin_ips = array_map('intval', $admin_ips);
$admin_ips = rs_wpss_sort_unique(array_flip($admin_ips));
} elseif (rs_wpss_is_user_admin()) {
$current_ip = rs_wpss_get_ip_addr();
rs_wpss_update_user_ip(NULL, TRUE, $admin_ips);
if (rs_wpss_is_valid_ip($current_ip)) {
$admin_ips = (array) $current_ip;
}
}
if (empty($admin_ips) || !is_array($admin_ips)) {
$last_admin_ip = get_option('spamshield_last_admin');
if (!empty($last_admin_ip) && rs_wpss_is_valid_ip($last_admin_ip)) {
$admin_ips = (array) $last_admin_ip;
}
}
$wpss_log_key = rs_wpss_get_log_key();
$wpss_log_key_uc = rs_wpss_casetrans('upper', $wpss_log_key);
$wpss_log_filnm = strpos(WPSS_SERVER_NAME_REV, WPSS_MDBUG_SERVER_NAME_REV) === 0 ? 'temp-comments-log.txt' : 'temp-comments-log-' . $wpss_log_key . '.txt';
$wpss_log_filns = array('', $wpss_log_filnm, 'temp-comments-log.init.txt', '.htaccess', 'htaccess.txt', 'htaccess.init.txt');
/* Filenames - log, log_empty, htaccess, htaccess,_orig, htaccess_empty */
$wpss_log_perlr = array(0775, 0664, 0664, 0664, 0664, 0664);
/* Permission level recommended */
$wpss_log_perlm = array(0755, 0644, 0644, 0644, 0644, 0644);
/* Permission level minimum */
$wpss_log_files = array();
/* Log files with full paths */
foreach ($wpss_log_filns as $f => $filn) {
$wpss_log_files[] = WPSS_PLUGIN_DATA_PATH . '/' . $filn;
}
/* 1 - Create temp-comments-log-{random hash}.txt if it doesn't exist */
clearstatcache();
if (!file_exists($wpss_log_files[1])) {
@chmod($wpss_log_files[2], 0664);
@copy($wpss_log_files[2], $wpss_log_files[1]);
@chmod($wpss_log_files[1], 0664);
}
if (!empty($mk_log)) {
return FALSE;
}
/* 2 - Create .htaccess if it doesn't exist */
clearstatcache();
if (!file_exists($wpss_log_files[3])) {
@chmod($wpss_log_files[0], 0775);
@chmod($wpss_log_files[4], 0664);
@chmod($wpss_log_files[5], 0664);
@rename($wpss_log_files[4], $wpss_log_files[3]);
@copy($wpss_log_files[5], $wpss_log_files[4]);
foreach ($wpss_log_files as $f => $file) {
@chmod($file, $wpss_log_perlr[$f]);
}
}
/* 3 - Check file permissions and fix */
clearstatcache();
$wpss_log_perms = array();
/* File permissions */
foreach ($wpss_log_files as $f => $file) {
$wpss_log_perms[] = substr(sprintf('%o', fileperms($file)), -4);
}
foreach ($wpss_log_perlr as $p => $perlr) {
if ($wpss_log_perms[$p] < $perlr || !wp_is_writable($wpss_log_files[$p])) {
foreach ($wpss_log_files as $f => $file) {
@chmod($file, $wpss_log_perlr[$f]);
}
/* Correct the permissions... */
break;
}
}
/* 4 - Clear files by copying fresh versions to existing files */
if (empty($clr_hta)) {
if (file_exists($wpss_log_files[1]) && file_exists($wpss_log_files[2])) {
@copy($wpss_log_files[2], $wpss_log_files[1]);
}
/* Log file */
}
if (file_exists($wpss_log_files[3]) && file_exists($wpss_log_files[5])) {
@copy($wpss_log_files[5], $wpss_log_files[3]);
}
/* .htaccess file */
/* 5 - Write .htaccess */
$wpss_htaccess_data = $wpss_access_ap22 = '';
$wpss_access_ap24 = 'Require all denied' . WPSS_EOL;
if (!empty($admin_ips) && is_array($admin_ips)) {
$ip_rgx = '^(' . str_replace(array('.', ':'), array('\\.', '\\:'), implode('|', $admin_ips)) . ')$';
$wpss_htaccess_data .= '<IfModule mod_setenvif.c>' . WPSS_EOL . "\t" . 'SetEnvIf Remote_Addr ' . $ip_rgx . ' WPSS_ACCESS_' . $wpss_log_key_uc . WPSS_EOL . '</IfModule>' . WPSS_EOL . WPSS_EOL;
$wpss_access_ap22 = "\t\t" . 'Allow from env=WPSS_ACCESS_' . $wpss_log_key_uc . WPSS_EOL;
$wpss_access_ap24 = 'Require env WPSS_ACCESS_' . $wpss_log_key_uc . WPSS_EOL;
}
$wpss_htaccess_data .= '<Files ' . $wpss_log_filnm . '>' . WPSS_EOL;
$wpss_htaccess_data .= "\t" . '# Apache 2.2' . WPSS_EOL . "\t" . '<IfModule !mod_authz_core.c>' . WPSS_EOL . "\t\t" . 'Order deny,allow' . WPSS_EOL . "\t\t" . 'Deny from all' . WPSS_EOL . $wpss_access_ap22 . "\t" . '</IfModule>' . WPSS_EOL . WPSS_EOL;
//.........这里部分代码省略.........
示例15: hmbkp_set_server_config_notices
function hmbkp_set_server_config_notices()
{
$notices = HM\BackUpWordPress\Notices::get_instance();
$messages = array();
if (!HM\BackUpWordPress\Backup::is_shell_exec_available()) {
$php_user = '<PHP USER>';
$php_group = '<PHP GROUP>';
} else {
$php_user = shell_exec('whoami');
$groups = explode(' ', shell_exec('groups'));
$php_group = reset($groups);
}
if (!is_dir(hmbkp_path())) {
$messages[] = sprintf(__('The backups directory can\'t be created because your %1$s directory isn\'t writable, run %2$s or %3$s or create the folder yourself.', 'backupwordpress'), '<code>' . esc_html(dirname(hmbkp_path())) . '</code>', '<code>chown ' . esc_html($php_user) . ':' . esc_html($php_group) . ' ' . esc_html(dirname(hmbkp_path())) . '</code>', '<code>chmod 777 ' . esc_html(dirname(hmbkp_path())) . '</code>');
}
if (is_dir(hmbkp_path()) && !wp_is_writable(hmbkp_path())) {
$messages[] = sprintf(__('Your backups directory isn\'t writable, run %1$s or %2$s or set the permissions yourself.', 'backupwordpress'), '<code>chown -R ' . esc_html($php_user) . ':' . esc_html($php_group) . ' ' . esc_html(hmbkp_path()) . '</code>', '<code>chmod -R 777 ' . esc_html(hmbkp_path()) . '</code>');
}
if (HM\BackUpWordPress\Backup::is_safe_mode_active()) {
$messages[] = sprintf(__('%1$s is running in %2$s, please contact your host and ask them to disable it. BackUpWordPress may not work correctly whilst %3$s is on.', 'backupwordpress'), '<code>PHP</code>', sprintf('<a href="%1$s">%2$s</a>', __('http://php.net/manual/en/features.safe-mode.php', 'backupwordpress'), __('Safe Mode', 'backupwordpress')), '<code>' . __('Safe Mode', 'backupwordpress') . '</code>');
}
if (defined('HMBKP_PATH') && HMBKP_PATH) {
// Suppress open_basedir warning https://bugs.php.net/bug.php?id=53041
if (!@file_exists(HMBKP_PATH)) {
$messages[] = sprintf(__('Your custom path does not exist', 'backupwordpress'));
} elseif (hmbkp_is_restricted_custom_path()) {
$messages[] = sprintf(__('Your custom path is unreachable due to a restriction set in your PHP configuration (open_basedir)', 'backupwordpress'));
} else {
if (!@is_dir(HMBKP_PATH)) {
$messages[] = sprintf(__('Your custom backups directory %1$s doesn\'t exist and can\'t be created, your backups will be saved to %2$s instead.', 'backupwordpress'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(hmbkp_path()) . '</code>');
}
if (@is_dir(HMBKP_PATH) && !wp_is_writable(HMBKP_PATH)) {
$messages[] = sprintf(__('Your custom backups directory %1$s isn\'t writable, new backups will be saved to %2$s instead.', 'backupwordpress'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(hmbkp_path()) . '</code>');
}
}
}
$test_backup = new HM\BackUpWordPress\Backup();
if (!is_readable($test_backup->get_root())) {
$messages[] = sprintf(__('Your site root path %s isn\'t readable.', 'backupwordpress'), '<code>' . $test_backup->get_root() . '</code>');
}
if (count($messages) > 0) {
$notices->set_notices('server_config', $messages, false);
}
}