I am using a theme that has a lot of tools I need for a project, the only issue is they have a really long company name and it is everywhere! The double lines are driving me mad.
I know how to replace a string on the frontend using the below code, but I dont know how to modify it for the admin area.
function replace_content($content)
{
$content = str_replace('##Replace Me##', '##With Something Else##',$content);
return $content;
}
add_filter('the_content','replace_content');
As far as I know the admin section doesn't have anything similar to the_content to filter off of, since any plugin/theme/extension could be writing to the backend in any way they want. You could probably find a good number of hooks to filter it out in most places (maybe the theme itself provides such hooks?) like you do with the content, but probably couldn't get all of them.
Given the way theme authors like to write their c̶r̶a̶p̶ code. I'm guessing this is hard coded into the theme, in which case the most viable option is unfortunately to edit the theme. If you can ssh into the server, command line tools like sed should make this basically a one-liner like the answer to this question.
If they happened to be nice enough to put their name in the database, you can use a plugin like Search & Replace to change all instances of it in the db.
Related
I have a WP blog with over 7500 posts and would like to run a "batch script" on all such posts, to apply some changes to each post's content. For example filter some words or reduce the number of characters/images etc.
I'm familiar with PHP, but I'm not really familiar with Wordpress and the WP Codex. I know what I need to code once I get access to the actual post content, but getting there and after that saving the new content to WP DB is what I don't know how to achieve.
What is the best (straightforward & easy) option - running some batch script through PHPMyAdmin or is there some WP plugin that can be modified to achieve arbitrary operations on posts' content?
Does anyone have such a batch script in their workspace, willing to share?
I finally found it by testing, and again "thanks dude" to the one who downvoted the question without answering, just because.
So, the way to parse WP posts (just for visitor output, without altering in wpdb) is to go to "/wp-includes/post-template.php" and alter the internals of the_content function, before the echo $content statement. That's the most straightforward, yet unsafe way (if you don't know what you're really doing). Another safer way is to actually use the apply_filter(the_content, 'your_filter') filter hook if you know your WP stuff.
That's it, happy PHP-ing!
This is my second day with wordpress and I would like to translate the whole website to my native language (Portuguese). I've translated a couple buttons and stuff, but it takes me a while to find where it is within the PHP codes, and, a friend of mine who works with wordpress, said it could be dangerous to alter the theme and cherry framework files.
I am looking for a tool/plugin where I can manually translate all the strings, and not use Google translate, as most plugins I've saw. Any tips?
Alright, so I managed to solve my problem with a WordPress plugin called Say What. After installing it, it's pretty simple to use! For instance, I have this string on my template:
<?php _e('Search for: ','cherry');?>"<?php the_search_query(); ?>"
Then, on Say What plugin, all I gotta do is:
Original String = Search for:
Text Domain = cherry
Replacement string = Buscar por:
It's working great! Thanks!
Ive been using wordpress for awhile now and wanted to try something different. Enter in my discovery of the world of static website generates. Now I have my eyes on Octopress which I know to be built on jekyll. Before I start getting dirty in ruby I want to know if its relatively possible to translate my current wordpress theme to a static site.
That's exactly what I did recently:
http://eduncan911.com/blog
I copied a friend's Wordpress theme (with permission) of almost the same design:
http://forgetfoo.com
"I want to know if its relatively possible"
To answer your first concern, the answer is a big ol' YES. That's what make Jekyll so good for these kind of things: it's just raw HTML and css and js in a few directories. Place them anywhere you like, and start cutting away at chunks in includes, wrap some plugins, etc and before you know it, you are rake generate and rake deploy.
Octopress makes it even sweeter by having a large number of plugins, a blog-like template system already structured*** (see below), and bunch of defaults all setup for blogging.
The issue with Octopress' theme is as I said above, it is purely setup as a blogging platform. You'd need to highly modify, or in my case just completely ignore, the template they have and just piggy back on the nice Github Pages, SCSS, and plugins it comes with and roll your own html templates. It's really really really easy.
Where do you start?
/source/index.html
You start here with this YAML file. At the top is a definition of layout, which is used to pick what "wrapper" or layout you want to surround this index.html content with. To make a new template, one like yours, I'd call it layout: fuse_homepage. Then go into source/_layouts/ and create a new `fuse_homepage.html'.
Start with your own theme and format as you want
But see, you don't even have to do that. Hell, just paste your entire homepage HTML right
into that source/index.html to start with (make sure to keep the --- YAML markers at the top, but get rid of the layout). Start there and break things out later when you get tired of coping and pasting the header/footers. Heck, just start there - make a fuse_header.html and fuse_footer.html and just share those for now.
Ignore Octopress' theme layout - it's just for hackers that don't do UX and just want to tweak things. Designers or people that like to control their code will want to roll your own.
It really is that flexible. However you want to break it up, you can. Want a new page, just call rake new_page["title"], which all this does is create either an /title.html, or /title/index.html, depending on your settings in the config file. But see, you don't even have to do that. Just create the file yourself - BAM, it is copied on deployment.
Regrets with Octopress
Trying to force the themes to do my bidding, chasing rabbits
I only regret trying to follow the Octopress' author's format - wasted so much time and got so turned off at Octopress. In the end, I just ignored it and did my own. Much easier, and I know where everything is. I also wanted nice and cleanly formatted HTML - a show that I care about my code. The default Octorpess theme and structure invites so many mis-placed tabs and spaces that it's just ugly. Doing your own, you are in full control, space by little space insert.
Importing posts
There's a huge amount of Google links to help you export your WRX from Wordpress, and to generate a the post files automagically. Be prepared to try several different ones as they aren't all perfect.
import comments into Disqus
Unless you are already using Disqus on Wordpress, you are going to have a horrible time with this one.
I can now claim myself to be an WRX/BlogML expert after my nearly 100 tries of importing and exporting and fixing and so on. There is no documentation on either importer (Disqus nor Wordpress) to tell you of the individual required fields. For example, Wordpress requires wp:comment_id to be set, and unique for each and every post you import whereas Disqus requires an wp:comment_email field, even though say it is optional (it's BS, argh).
Be prepared to hack code. It is a hacker's framework after all
Do note though: it is a lot of work to hack around the static site. Doing your own template will save you so much time. You'll also may want to write your own custom plugins, which I did, to get around the bugs in peoples github repos - it's pretty easy, but does require coding.
I spent about a month off and on until I got my new blog/static site to where I liked it for launch. A lot more than I wanted, but it was "fun" learning new languages (Ruby, Python, installed Debian linux in a VM cause Windows just sucks at that stuff).
If you aren't prepared to write that much, there are a couple more static site generators out there as I blogged about (hey, got to show off my Octopress and custom theme!):
http://eduncan911.com/software/the-static-blog-boom.html
Btw, nice site...
I'm relatively new to Magento and working on a site build for a client and they simply need a list of phrases used throughout the site to be sent to a translator. I'm a little surprised that there isn't something simple and built into Magento for easily pulling this stuff out, which is why I'm writing here now. Is there a relatively simple way to extract translation phrases from a Magento app? Something built in that might not be obvious (to me)? or some useful library out there? This includes everything used in the templates (or controllers) like so:
$this->__("Some phrase on my website...");
... as well as cases in the layout XML where the 'translate' attribute is set, etc.
And taking this one step further, I'm aware of the available translations available from Magento here: http://www.magentocommerce.com/translations -- is there something simple to make sure I'm not double-doing it for phrases that might already exist in these packs?
And further still, is there a something to pull all translatables out of the database?
And if the answer for all this turns out to be 'no', I need to be very thorough with this so any advice on pitfalls or particular spots I need to be aware of where I might not think of pulling translations from, how you might have achieved something like this before, etc. -- I would love to hear your tips. Thanks!
I know I'm late, but anyway, I’ve just uploaded an extension that does that: Language CSV Files Generator.
It only extracts strings from .php and .phtml files, I have no idea of how to get the .xml ones. Hope that someone out there could share some idea.
hope you like it
Take a look in /app/locale/(language_country)/*.csv files.
There are different solutions to get the strings from CSV files of Magento:
check the links The Ultimate Guide to Translating Magento (using Translation Memory software)
and How to translate Magento using OmegaT software
Do you know how wordpress decides which related posts to show?I mean I know if it has tags, then it's easy but if it doesn't?
Best Regards,
Generally the 'related post' function of a Wordpress Blog is created by the owner of the blog, or using a plugin. I can imagine that those plugins either look for new posts with similar tags or in the same category as the post it is displaying.
As far as my knowledge extends, I do not believe that Wordpress has a show_related_posts function, although I may be wrong. If it does, it would be simple enough to look it up on the documentation at wordpress.org.
Also, another good part about OpenSource programming is that you can simply go in and look at any of the code that you are curious about. I personally use Notepad++, and when I find a function in Wordpress or any other CMS I am not famillar with, I simply copy and paste the function name, and do a Multi-File search on the function to figure out where it is declared.
I'm going to have to go with Chacha102, as far as I know this can only be done using plugins or by hacking the code yourself.
I did something similar by falling back on the post's category if it had no tags, works pretty well too.
This guy has the leading plugin for related posts. I'd download that and take a peek at his code and see how he does it. Then you can reverse engineer it and make it your own. The beauty of opensource.
http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/