$links_mass
.function links_remove () {
$args = array ('numberposts' => 9999);
$allposts = get_posts( $args );
foreach( $allposts as $post ) {
$id = $post->ID;
$content = $post->post_content;
$links_mass=array(/*Сотни ссылок через запятую*/);
foreach($links_mass as $link) {
$pattern = '/<a href="'/.$link./'" (.+?)>|<\/a>/'; /* тут вся проблема*/
$new_content = preg_replace ($pattern, '', $content);
}
$new_post = array();
$new_post['ID'] = $id;
$new_post['post_content'] = $new_content;
wp_update_post( $new_post );
}
}
preg_quote()
href
может быть не только самым первым атрибутом в теге <a>
и после него может отсутствовать пробел. $svg = __DIR__ . '/scheme.svg';
$svg_blob = file_get_contents($svg);
$absolute_path = __DIR__;
$svg_blob = preg_replace_callback('/<image xlink:href="([^"]+)"/i', function($match, $a, $b) use ($absolute_path) {
$path_to_image = $absolute_path . '/' . $match[1];
$image_base64 = base64_encode(file_get_contents($path_to_image));
list($w, $h, $type) = getimagesize($path_to_image);
switch ($type) {
case IMAGETYPE_PNG:
$type = 'image/png';
break;
case IMAGETYPE_JPEG:
$type = 'image/jpeg';
}
return "<image xlink:href=\"data:$type;base64,$image_base64\"";
}, $svg_blob);
$imagic = new Imagick();
$imagic->readImageBlob($svg_blob);
$imagic->setImageFormat("png24");
header('Content-Type: image/png');
echo $imagic;
$imagic->clear();
$imagic->destroy();
private function upload($uri, $temp)
{
if (preg_match('/[^\/]+(.(gz)|(bz2))$/i', $uri, $match)) {
$compress = array(
'.gz' => 'compress.zlib://',
'.bz2' => 'compress.bzip2://'
);
$source = $compress[ $match[1] ] . $uri;
} else {
$source = $uri;
}
$hR = fopen($source, "r");
$hW = fopen($temp, "w");
$part = 0;
while ( ! feof($hR)) {
$str = fread($hR, 1024);
if ($part == 0 && stripos($str, '<?xml') === false) {
throw new \Exception('Передаваемый файл не XML.');
}
fwrite($hW, $str, strlen($str));
$part++;
}
fclose($hW);
fclose($hR);
}
$data['base'] = $server;
if ($this->request->server['HTTPS']) {
$data['base'] = HTTPS_SERVER;
} else {
$data['base'] = HTTP_SERVER;
}
# It must be the last
category:
path: "/{alias}"
defaults: { _controller: "AppBundle:Default:category" }
requirements:
alias: "[a-z_-]+(\/[a-z_-]+)*"
/**
* @ParamConverter("category", class="AppBundle:Category")
*/
public function categoryAction(Category $category, Request $request)
{
$id = $request->query->getInt('id');
if (null == $id) {
return $this->run('index', $category, $request); // indexAction
} else {
return $this->run('details', $category, $id); // detailsAction
}
}
private function run($actionName, $category)
{
$params = func_get_args();
array_shift($params);
$namespace = "\\AppBundle\\Controller\\". $category->getController() . 'Controller';
$actionName .= 'Action';
/** @var Controller $controller */
$controller = new $namespace();
$controller->setContainer($this->container);
return call_user_func_array(array($controller, $actionName), $params);
}
$category->getController()
как раз его возвращает. <input type="text" onkeydown="return specialText(this, event)">
function specialText(element, event)
{
if (
event.keyCode == 69 ||
event.keyCode == 189 ||
element.value.length >= 100
) {
return false;
}
}
<input type="text" maxlength="100" onkeydown="if (event.keyCode == 69 || event.keyCode == 189) return false">