add url alt and hover text
This commit is contained in:
parent
b886b513ab
commit
7b2b06deef
@ -21,6 +21,10 @@ class ComicPressBackendURL extends ComicPressBackend {
|
||||
$valid_urls[$type] = $url;
|
||||
if ($type == $default_type) { $key = substr(md5($url), 0, 10); }
|
||||
}
|
||||
} else {
|
||||
if (strpos($type, '__') === 0) {
|
||||
$valid_urls[$type] = $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -57,7 +61,14 @@ class ComicPressBackendURLFactory {
|
||||
if (isset($meta[$key])) {
|
||||
$backend = new ComicPressBackendURL();
|
||||
$backend->id = $id;
|
||||
$backend->urls_by_type = $meta[$key];
|
||||
$backend->urls_by_type = array();
|
||||
foreach ($meta[$key] as $k => $v) {
|
||||
if (strpos($k, '__') === 0) {
|
||||
$backend->{substr($k, 2)} = $v;
|
||||
} else {
|
||||
$backend->urls_by_type[$k] = $v;
|
||||
}
|
||||
}
|
||||
return $backend;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ class ComicPressBackendUrlFactoryTest extends PHPUnit_Framework_TestCase {
|
||||
'comic' => 'comic',
|
||||
'rss' => 'rss'
|
||||
);
|
||||
$valid_backend->alt_text = 'alt text';
|
||||
$valid_backend->hover_text = 'hover text';
|
||||
|
||||
return array(
|
||||
array('', false),
|
||||
@ -60,7 +62,14 @@ class ComicPressBackendUrlFactoryTest extends PHPUnit_Framework_TestCase {
|
||||
function testGenerateFromID($id, $expected_result) {
|
||||
wp_insert_post((object)array('ID' => 1));
|
||||
|
||||
update_post_meta(1, 'backend_url_image_urls', array('12345' => array('comic' => 'comic', 'rss' => 'rss')));
|
||||
update_post_meta(1, 'backend_url_image_urls', array(
|
||||
'12345' => array(
|
||||
'comic' => 'comic',
|
||||
'rss' => 'rss',
|
||||
'__alt_text' => 'alt text',
|
||||
'__hover_text' => 'hover text'
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertEquals($expected_result, $this->fa->generate_from_id($id));
|
||||
}
|
||||
|
@ -21,12 +21,16 @@ class ComicPressBackendUrlTest extends PHPUnit_Framework_TestCase {
|
||||
'test' => array(
|
||||
'comic' => 'http://test/test',
|
||||
'rss' => 'http://test/test2',
|
||||
'__alt_text' => 'alt text',
|
||||
'__hover_text' => 'hover text',
|
||||
)
|
||||
),
|
||||
array(
|
||||
$key => array(
|
||||
'comic' => 'http://test/test',
|
||||
'rss' => 'http://test/test2'
|
||||
'rss' => 'http://test/test2',
|
||||
'__alt_text' => 'alt text',
|
||||
'__hover_text' => 'hover text',
|
||||
)
|
||||
),
|
||||
)
|
||||
|
@ -1,5 +1,3 @@
|
||||
<?php
|
||||
|
||||
set_include_path(realpath(dirname(__FILE__) . '/../classes') . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user