cacycleworks
Forum Replies Created
-
Forum: Plugins
In reply to: Get Parent PagesIn the event Google brings more visitors here, I am doing the exact same thing as spiralstarez only the purpose is to prevent XSS injection into the URL of wordpress pages. So I need to know what I think my permalink should be before I call get_header();. ??
This handy gem will get you for pages what get_category_parents() does for posts. I guess I should have called it get_page_parents()… ??
function page_ancestory( $id=0, $separator="/" ){ $itisme=get_post($id); $lineage=$itisme->post_name; $parentID=$itisme->post_parent; while( $parentID != 0 ){ $parent=get_post($parentID); $lineage=$parent->post_name.$separator.$lineage; $parentID=$parent->post_parent; } return $lineage; } echo page_ancestory($post->ID);
In spiralstarez‘s case, the output would be:
about/1/1.1/1.2/1.2.1/1.2.2
Assuming that the above “words” are page “slugs”.
OH! I forgot to mention that $post works anywhere on a “page” template for me, so doesn’t need to be in the loop.
Reference: codex for get_post()Also, be aware that $post->post_content IS the whole page (or post) itself, so this child of the object can be bigger than you might think … and spools out ALL of that html and if you’re not paying attention, you think something broke, when it actually didn’t.
To see what’s going on with an array or object, I will do this:
<pre><? print_r($post); ?></pre>
But in our case, this makes the “page” twice as long and the only hint is the preformatting of the “post_content”. To make things better, if I am working outside the loop, I will often do this:
<pre><? unset($post->post_content); print_r($post); ?></pre>
Which will make the output more friendly:
[ID] => 146 [post_author] => 1 [post_date] => 2007-12-12 12:53:28 [post_date_gmt] => 2007-12-12 20:53:28 [post_content] => [post_title] => Terms & Conditions [post_category] => 0 [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => terms-conditions [to_ping] => [pinged] => [post_modified] => 2007-12-14 14:47:54 [post_modified_gmt] => 2007-12-14 22:47:54 [post_content_filtered] => [post_parent] => 6 [guid] => https://qa.mydomain.com/wordpress/policies/terms-conditions [menu_order] => 0 [post_type] => page [post_mime_type] => [comment_count] => 0
And from seeing this, you can see that this post’s parent is policies (from the guid) and policies’s ID is 6.
?? Chris
Forum: Fixing WordPress
In reply to: Line break issuesOh wow… this it the fix:
https://plugins.baptiste.us/plugins/xinha4wp/This gentleman has enabled a rich text editor to work as a plug in with WP.
NOTE: you leave the rich text editor disabled … this one shows up when you go to edit a page. It has a lot of functions, but it definitely didn’t do that weird “P” thing all over my html. ?? It also left my <div id=”red-box”> alone, which WP+TinyMCE couldn’t do. ?? ??
Forum: Fixing WordPress
In reply to: wp screwed the html codeOh wow… this it the fix:
https://plugins.baptiste.us/plugins/xinha4wp/This gentleman has enabled a rich text editor to work as a plug in with WP.
NOTE: you leave the rich text editor disabled … this one shows up when you go to edit a page. It has a lot of functions, but it definitely didn’t do that weird “P” thing all over my html. ?? It also left my <div id=”red-box”> alone, which WP+TinyMCE couldn’t do. ?? ??
Forum: Fixing WordPress
In reply to: Line break issuesNo, that didn’t work either. Please look here for the hack I got to work with both “plain text” as well as my own “html hack” code input….
Forum: Fixing WordPress
In reply to: wp screwed the html codeOK, I think this hack works…
In wpautop()… here are my snippets:
Initially, I removed any <P> tags in the document since they’ll be replicated by the wpautop() function…
function wpautop($pee, $br = 1) { //ckck did these two $pee = preg_replace('|<p>|', "", $pee); $pee = preg_replace('|<P>|', "", $pee); //--end ckck
and then at the end I did this:
//ckck did this: strip any leading pee if( stripos( $pee, "<P>") < 6 ) { $pee = substr( $pee, stripos( $pee, "<P>" )+3 ); } $pee = "\n<!-- begin content spooled from db -->\n".$pee."\n<!-- end content spooled from db -->\n";
I check to see if there is a <P> and the i in stripos means case-insensitive and then remove it.
I wish I knew regex (regular expressions) better. There is a lot of code in this function, but I think they juuust missed the mark with their conditions. I bet a couple “simple” edits to the pattern matching by a seasoned regex grand wizard would fix it without my hacks.
Also, using some of PHP’s str functions instead of preg_replace() would make this execute far less code.
Forum: Fixing WordPress
In reply to: wp screwed the html codenevermind … that function is actually used for the OUTPUT of the html to the posts and pages from the DC, too. ??
Forum: Fixing WordPress
In reply to: wp screwed the html codeYeah, turns out the “code” / “html” tool was screwing with html tags as well.
Try this:
https://www.ads-software.com/support/topic/111291/page/2?replies=31#post-662446worked for me…
The function wpautop() has a lot of preg_replace commands with much much HTML tag swapping. Ew. I did the above simple edit to wpautop() and the html served to the page is identical to the html I pasted into the code view window.
BTW, the “fix” is to put
return $pee;
as the first line in that function, bypassing all of the replaces.Forum: Fixing WordPress
In reply to: Line break issueswow, this really is amazing. one would think that editing in code/html mode meant you keep some control. i’m trying to get a site up and haven’t bothered to do much more looking, but this fixed the problem for me:
1) turn off the rich text editor in user profile
2) edit file: (base) wp-includes/formatting.phpafter line 62 which has:function wpautop($pee, $br = 1) {
add this: return $pee;And wpautop will not mess with your html tags much … it does still convert <br> to < br /> and it performs the php html_encode (or htmlidentities) function to special characters, like quotes.
Here is I found the above file to edit:
linux prompt at wp-install-dir$ grep -Rn "function wpautop" * grep: wp-content/plugins/aa-rewriterules-viewer: Permission denied wp-includes/formatting.php:62:function wpautop($pee, $br = 1) { wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js:571:function wpautop(pee) { linux prompt at wp-install-dir$
Grep has been amazing at understanding the layer upon layer of WP’s innerworkings.
Forum: Fixing WordPress
In reply to: wp screwed the html codeAh yes, the google-foo provides quick answer in wp support
From: HandySolo
Users -> Your Profile.
Top checkbox – check it. Done.Tested and it will preserve html you put in there.
Forum: Fixing WordPress
In reply to: wp screwed the html codeYes, it is messing with me, too. Totally not allowing me to put the submit button on form. ?? Sometimes, just when I’m really liking WP, stuff like this crops up. I’ll have a solution by day’s end that I’ll share.
Did anyone try this db-manager plug-in? It might let you blast whatever you want into the db via the WP interface, but I’ll consider this a last resort.
I’ve gotten pretty good at figuring out what WP is doing and finding good ways of altering reality — usually via not using their easier tools and instead implementing my own hack in the template php file using their lower-level functions that drive their “user interface” wp_ type tools talked about in the codex.
?? Chris
Forum: Themes and Templates
In reply to: How to detect current archive pageaaahhhhhhhhhh yessss:
$sb_max_page = intval($wp_query->max_num_pages);
That is brilliant. I was wanting to format the area of the prev / next links but in a way that I needed to know in advance if there were more pages. This is perfect!
It lets me have a well behaved and informative navigation at the end of the page. ??
$sb_max_page = intval($wp_query->max_num_pages); if( $sb_max_page > 1 ) { ?> <span id="red-box" style="text-align:center"> <?php previous_posts_link('« Newer Entries'); if( $paged > 1 ) { echo " - Page $paged of $sb_max_page"; // will be true if we have a "full" page of posts: if ( $wp_query->post_count == get_option('posts_per_page') ) { echo " - "; } } if( $paged == '') { echo "Page 1 of $sb_max_page "; } next_posts_link('Older Entries »'); ?> </span><P></p> <? }
Forum: Installing WordPress
In reply to: CSS style by wp_list_pages()Hi! Sorry, I didn’t notice your reply. Didn’t realize I wouldn’t be notified so now I’ve tried the Join button at the bottom of the page. ??
I ended up using this css to make the categories in the sidebar appear without any li or ul formatting:
/* Misery in trying to align the Pages output to other sidebar goodies... .sidebar > li .pagenav > ul > li .page_item page-item-2 > a */ .sidebar .pagenav { margin: 0px; list-style: inside; list-style-type: none; padding: 0px; list-style-position: inside } .sidebar .pagenav h2 { margin: 0px 0px .1em 0; padding: 0px; } .sidebar .pagenav li { margin: 0px; padding: 0px; } .sidebar .pagenav ul { margin: 0px; padding: 0px; } .sidebar .pagenav ul li { margin: -.3em 0px 0px 0px; padding: 0px; } /* IE 6 list hack :: FF doesn't see this... https://jake.cfwebtools.com/index.cfm/2007/5/1/CSS-Browser-Hacks */ * html .sidebar .pagenav h2 { margin: 0px 0px .1em -1em; padding: 0px; } /* IE 7 list hack :: FF doesn't see this... https://jake.cfwebtools.com/index.cfm/2007/5/1/CSS-Browser-Hacks */ *:first-child+html .sidebar .pagenav h2 { margin: 0px 0px .1em -1em; padding: 0px; }
The page_item and page_nav css were amazingly difficult to sort out from my site-wide css included page but the above did what I want.
Forum: Installing WordPress
In reply to: CSS style by wp_list_pages()hi,
i made a <div class=sidebar> wrapper around my sidebar and then used the follow css style to define sidebar:
.sidebar { list-style-type:none; } .sidebar p { margin-top:10px; margin-bottom:10px; border-bottom: solid 1px gray; } .sidebar ul { margin:-5px; list-style-type:none; } .sidebar li { list-style-type:none; }
But now i’m trying to override the page_item style without much luck… ??